1bf215546Sopenharmony_ci/************************************************************************** 2bf215546Sopenharmony_ci * 3bf215546Sopenharmony_ci * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian. 4bf215546Sopenharmony_ci * Copyright 2014 Advanced Micro Devices, Inc. 5bf215546Sopenharmony_ci * All Rights Reserved. 6bf215546Sopenharmony_ci * 7bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 8bf215546Sopenharmony_ci * copy of this software and associated documentation files (the 9bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 10bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 11bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to 12bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 13bf215546Sopenharmony_ci * the following conditions: 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the 16bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 17bf215546Sopenharmony_ci * of the Software. 18bf215546Sopenharmony_ci * 19bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 22bf215546Sopenharmony_ci * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR 23bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26bf215546Sopenharmony_ci * 27bf215546Sopenharmony_ci **************************************************************************/ 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#ifndef VA_PRIVATE_H 30bf215546Sopenharmony_ci#define VA_PRIVATE_H 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci#include <assert.h> 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci#include <va/va.h> 35bf215546Sopenharmony_ci#include <va/va_backend.h> 36bf215546Sopenharmony_ci#include <va/va_backend_vpp.h> 37bf215546Sopenharmony_ci#include <va/va_drmcommon.h> 38bf215546Sopenharmony_ci 39bf215546Sopenharmony_ci#include "pipe/p_video_enums.h" 40bf215546Sopenharmony_ci#include "pipe/p_video_codec.h" 41bf215546Sopenharmony_ci#include "pipe/p_video_state.h" 42bf215546Sopenharmony_ci 43bf215546Sopenharmony_ci#include "vl/vl_compositor.h" 44bf215546Sopenharmony_ci#include "vl/vl_csc.h" 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_ci#include "util/u_dynarray.h" 47bf215546Sopenharmony_ci#include "os/os_thread.h" 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ci#ifndef VA_RT_FORMAT_YUV420_10 50bf215546Sopenharmony_ci#define VA_RT_FORMAT_YUV420_10 VA_RT_FORMAT_YUV420_10BPP 51bf215546Sopenharmony_ci#endif 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_ci#define VL_VA_DRIVER(ctx) ((vlVaDriver *)ctx->pDriverData) 54bf215546Sopenharmony_ci#define VL_VA_PSCREEN(ctx) (VL_VA_DRIVER(ctx)->vscreen->pscreen) 55bf215546Sopenharmony_ci 56bf215546Sopenharmony_ci#define VL_VA_MAX_IMAGE_FORMATS 12 57bf215546Sopenharmony_ci#define VL_VA_ENC_GOP_COEFF 16 58bf215546Sopenharmony_ci 59bf215546Sopenharmony_ci#define UINT_TO_PTR(x) ((void*)(uintptr_t)(x)) 60bf215546Sopenharmony_ci#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x))) 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ci#define SOI 2 63bf215546Sopenharmony_ci#define DQT (4 + 4 * 65) 64bf215546Sopenharmony_ci#define DHT (4 + 2 * 29 + 2 * 179) 65bf215546Sopenharmony_ci#define DRI 6 66bf215546Sopenharmony_ci#define SOF (10 + 255 * 3) 67bf215546Sopenharmony_ci#define SOS (8 + 4 * 2) 68bf215546Sopenharmony_ci#define MAX_MJPEG_SLICE_HEADER_SIZE (SOI + DQT + DHT + DRI + SOF + SOS) 69bf215546Sopenharmony_ci 70bf215546Sopenharmony_cistatic inline enum pipe_video_chroma_format 71bf215546Sopenharmony_ciChromaToPipe(int format) 72bf215546Sopenharmony_ci{ 73bf215546Sopenharmony_ci switch (format) { 74bf215546Sopenharmony_ci case VA_RT_FORMAT_YUV420: 75bf215546Sopenharmony_ci case VA_RT_FORMAT_YUV420_10BPP: 76bf215546Sopenharmony_ci return PIPE_VIDEO_CHROMA_FORMAT_420; 77bf215546Sopenharmony_ci case VA_RT_FORMAT_YUV422: 78bf215546Sopenharmony_ci return PIPE_VIDEO_CHROMA_FORMAT_422; 79bf215546Sopenharmony_ci case VA_RT_FORMAT_YUV444: 80bf215546Sopenharmony_ci return PIPE_VIDEO_CHROMA_FORMAT_444; 81bf215546Sopenharmony_ci default: 82bf215546Sopenharmony_ci return PIPE_VIDEO_CHROMA_FORMAT_NONE; 83bf215546Sopenharmony_ci } 84bf215546Sopenharmony_ci} 85bf215546Sopenharmony_ci 86bf215546Sopenharmony_cistatic inline enum pipe_format 87bf215546Sopenharmony_ciVaFourccToPipeFormat(unsigned format) 88bf215546Sopenharmony_ci{ 89bf215546Sopenharmony_ci switch(format) { 90bf215546Sopenharmony_ci case VA_FOURCC('N','V','1','2'): 91bf215546Sopenharmony_ci return PIPE_FORMAT_NV12; 92bf215546Sopenharmony_ci case VA_FOURCC('P','0','1','0'): 93bf215546Sopenharmony_ci return PIPE_FORMAT_P010; 94bf215546Sopenharmony_ci case VA_FOURCC('P','0','1','6'): 95bf215546Sopenharmony_ci return PIPE_FORMAT_P016; 96bf215546Sopenharmony_ci case VA_FOURCC('I','4','2','0'): 97bf215546Sopenharmony_ci return PIPE_FORMAT_IYUV; 98bf215546Sopenharmony_ci case VA_FOURCC('Y','V','1','2'): 99bf215546Sopenharmony_ci return PIPE_FORMAT_YV12; 100bf215546Sopenharmony_ci case VA_FOURCC('Y','U','Y','V'): 101bf215546Sopenharmony_ci case VA_FOURCC('Y','U','Y','2'): 102bf215546Sopenharmony_ci return PIPE_FORMAT_YUYV; 103bf215546Sopenharmony_ci case VA_FOURCC('U','Y','V','Y'): 104bf215546Sopenharmony_ci return PIPE_FORMAT_UYVY; 105bf215546Sopenharmony_ci case VA_FOURCC('B','G','R','A'): 106bf215546Sopenharmony_ci return PIPE_FORMAT_B8G8R8A8_UNORM; 107bf215546Sopenharmony_ci case VA_FOURCC('R','G','B','A'): 108bf215546Sopenharmony_ci return PIPE_FORMAT_R8G8B8A8_UNORM; 109bf215546Sopenharmony_ci case VA_FOURCC('B','G','R','X'): 110bf215546Sopenharmony_ci return PIPE_FORMAT_B8G8R8X8_UNORM; 111bf215546Sopenharmony_ci case VA_FOURCC('R','G','B','X'): 112bf215546Sopenharmony_ci return PIPE_FORMAT_R8G8B8X8_UNORM; 113bf215546Sopenharmony_ci default: 114bf215546Sopenharmony_ci assert(0); 115bf215546Sopenharmony_ci return PIPE_FORMAT_NONE; 116bf215546Sopenharmony_ci } 117bf215546Sopenharmony_ci} 118bf215546Sopenharmony_ci 119bf215546Sopenharmony_cistatic inline unsigned 120bf215546Sopenharmony_ciPipeFormatToVaFourcc(enum pipe_format p_format) 121bf215546Sopenharmony_ci{ 122bf215546Sopenharmony_ci switch (p_format) { 123bf215546Sopenharmony_ci case PIPE_FORMAT_NV12: 124bf215546Sopenharmony_ci return VA_FOURCC('N','V','1','2'); 125bf215546Sopenharmony_ci case PIPE_FORMAT_P010: 126bf215546Sopenharmony_ci return VA_FOURCC('P','0','1','0'); 127bf215546Sopenharmony_ci case PIPE_FORMAT_P016: 128bf215546Sopenharmony_ci return VA_FOURCC('P','0','1','6'); 129bf215546Sopenharmony_ci case PIPE_FORMAT_IYUV: 130bf215546Sopenharmony_ci return VA_FOURCC('I','4','2','0'); 131bf215546Sopenharmony_ci case PIPE_FORMAT_YV12: 132bf215546Sopenharmony_ci return VA_FOURCC('Y','V','1','2'); 133bf215546Sopenharmony_ci case PIPE_FORMAT_UYVY: 134bf215546Sopenharmony_ci return VA_FOURCC('U','Y','V','Y'); 135bf215546Sopenharmony_ci case PIPE_FORMAT_YUYV: 136bf215546Sopenharmony_ci return VA_FOURCC('Y','U','Y','V'); 137bf215546Sopenharmony_ci case PIPE_FORMAT_B8G8R8A8_UNORM: 138bf215546Sopenharmony_ci return VA_FOURCC('B','G','R','A'); 139bf215546Sopenharmony_ci case PIPE_FORMAT_R8G8B8A8_UNORM: 140bf215546Sopenharmony_ci return VA_FOURCC('R','G','B','A'); 141bf215546Sopenharmony_ci case PIPE_FORMAT_B8G8R8X8_UNORM: 142bf215546Sopenharmony_ci return VA_FOURCC('B','G','R','X'); 143bf215546Sopenharmony_ci case PIPE_FORMAT_R8G8B8X8_UNORM: 144bf215546Sopenharmony_ci return VA_FOURCC('R','G','B','X'); 145bf215546Sopenharmony_ci default: 146bf215546Sopenharmony_ci assert(0); 147bf215546Sopenharmony_ci return -1; 148bf215546Sopenharmony_ci } 149bf215546Sopenharmony_ci} 150bf215546Sopenharmony_ci 151bf215546Sopenharmony_cistatic inline VAProfile 152bf215546Sopenharmony_ciPipeToProfile(enum pipe_video_profile profile) 153bf215546Sopenharmony_ci{ 154bf215546Sopenharmony_ci switch (profile) { 155bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE: 156bf215546Sopenharmony_ci return VAProfileMPEG2Simple; 157bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG2_MAIN: 158bf215546Sopenharmony_ci return VAProfileMPEG2Main; 159bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE: 160bf215546Sopenharmony_ci return VAProfileMPEG4Simple; 161bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE: 162bf215546Sopenharmony_ci return VAProfileMPEG4AdvancedSimple; 163bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_VC1_SIMPLE: 164bf215546Sopenharmony_ci return VAProfileVC1Simple; 165bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_VC1_MAIN: 166bf215546Sopenharmony_ci return VAProfileVC1Main; 167bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_VC1_ADVANCED: 168bf215546Sopenharmony_ci return VAProfileVC1Advanced; 169bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE: 170bf215546Sopenharmony_ci return VAProfileH264ConstrainedBaseline; 171bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN: 172bf215546Sopenharmony_ci return VAProfileH264Main; 173bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH: 174bf215546Sopenharmony_ci return VAProfileH264High; 175bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_HEVC_MAIN: 176bf215546Sopenharmony_ci return VAProfileHEVCMain; 177bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_HEVC_MAIN_10: 178bf215546Sopenharmony_ci return VAProfileHEVCMain10; 179bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_JPEG_BASELINE: 180bf215546Sopenharmony_ci return VAProfileJPEGBaseline; 181bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_VP9_PROFILE0: 182bf215546Sopenharmony_ci return VAProfileVP9Profile0; 183bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_VP9_PROFILE2: 184bf215546Sopenharmony_ci return VAProfileVP9Profile2; 185bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_AV1_MAIN: 186bf215546Sopenharmony_ci return VAProfileAV1Profile0; 187bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG4_AVC_EXTENDED: 188bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH10: 189bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH422: 190bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH444: 191bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG4_AVC_CONSTRAINED_BASELINE: 192bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_HEVC_MAIN_12: 193bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_HEVC_MAIN_STILL: 194bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_HEVC_MAIN_444: 195bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_UNKNOWN: 196bf215546Sopenharmony_ci return VAProfileNone; 197bf215546Sopenharmony_ci default: 198bf215546Sopenharmony_ci assert(0); 199bf215546Sopenharmony_ci return -1; 200bf215546Sopenharmony_ci } 201bf215546Sopenharmony_ci} 202bf215546Sopenharmony_ci 203bf215546Sopenharmony_cistatic inline enum pipe_video_profile 204bf215546Sopenharmony_ciProfileToPipe(VAProfile profile) 205bf215546Sopenharmony_ci{ 206bf215546Sopenharmony_ci switch (profile) { 207bf215546Sopenharmony_ci case VAProfileMPEG2Simple: 208bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE; 209bf215546Sopenharmony_ci case VAProfileMPEG2Main: 210bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_MPEG2_MAIN; 211bf215546Sopenharmony_ci case VAProfileMPEG4Simple: 212bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_MPEG4_SIMPLE; 213bf215546Sopenharmony_ci case VAProfileMPEG4AdvancedSimple: 214bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE; 215bf215546Sopenharmony_ci case VAProfileVC1Simple: 216bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_VC1_SIMPLE; 217bf215546Sopenharmony_ci case VAProfileVC1Main: 218bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_VC1_MAIN; 219bf215546Sopenharmony_ci case VAProfileVC1Advanced: 220bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_VC1_ADVANCED; 221bf215546Sopenharmony_ci case VAProfileH264ConstrainedBaseline: 222bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE; 223bf215546Sopenharmony_ci case VAProfileH264Main: 224bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN; 225bf215546Sopenharmony_ci case VAProfileH264High: 226bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH; 227bf215546Sopenharmony_ci case VAProfileHEVCMain: 228bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_HEVC_MAIN; 229bf215546Sopenharmony_ci case VAProfileHEVCMain10: 230bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_HEVC_MAIN_10; 231bf215546Sopenharmony_ci case VAProfileJPEGBaseline: 232bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_JPEG_BASELINE; 233bf215546Sopenharmony_ci case VAProfileVP9Profile0: 234bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_VP9_PROFILE0; 235bf215546Sopenharmony_ci case VAProfileVP9Profile2: 236bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_VP9_PROFILE2; 237bf215546Sopenharmony_ci case VAProfileAV1Profile0: 238bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_AV1_MAIN; 239bf215546Sopenharmony_ci case VAProfileNone: 240bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_UNKNOWN; 241bf215546Sopenharmony_ci default: 242bf215546Sopenharmony_ci return PIPE_VIDEO_PROFILE_UNKNOWN; 243bf215546Sopenharmony_ci } 244bf215546Sopenharmony_ci} 245bf215546Sopenharmony_ci 246bf215546Sopenharmony_citypedef struct { 247bf215546Sopenharmony_ci struct vl_screen *vscreen; 248bf215546Sopenharmony_ci struct pipe_context *pipe; 249bf215546Sopenharmony_ci struct handle_table *htab; 250bf215546Sopenharmony_ci struct vl_compositor compositor; 251bf215546Sopenharmony_ci struct vl_compositor_state cstate; 252bf215546Sopenharmony_ci vl_csc_matrix csc; 253bf215546Sopenharmony_ci mtx_t mutex; 254bf215546Sopenharmony_ci char vendor_string[256]; 255bf215546Sopenharmony_ci} vlVaDriver; 256bf215546Sopenharmony_ci 257bf215546Sopenharmony_citypedef struct { 258bf215546Sopenharmony_ci VAImage *image; 259bf215546Sopenharmony_ci 260bf215546Sopenharmony_ci struct u_rect src_rect; 261bf215546Sopenharmony_ci struct u_rect dst_rect; 262bf215546Sopenharmony_ci 263bf215546Sopenharmony_ci struct pipe_sampler_view *sampler; 264bf215546Sopenharmony_ci} vlVaSubpicture; 265bf215546Sopenharmony_ci 266bf215546Sopenharmony_citypedef struct { 267bf215546Sopenharmony_ci VABufferType type; 268bf215546Sopenharmony_ci unsigned int size; 269bf215546Sopenharmony_ci unsigned int num_elements; 270bf215546Sopenharmony_ci void *data; 271bf215546Sopenharmony_ci struct { 272bf215546Sopenharmony_ci struct pipe_resource *resource; 273bf215546Sopenharmony_ci struct pipe_transfer *transfer; 274bf215546Sopenharmony_ci } derived_surface; 275bf215546Sopenharmony_ci unsigned int export_refcount; 276bf215546Sopenharmony_ci VABufferInfo export_state; 277bf215546Sopenharmony_ci unsigned int coded_size; 278bf215546Sopenharmony_ci struct pipe_video_buffer *derived_image_buffer; 279bf215546Sopenharmony_ci} vlVaBuffer; 280bf215546Sopenharmony_ci 281bf215546Sopenharmony_citypedef struct { 282bf215546Sopenharmony_ci struct pipe_video_codec templat, *decoder; 283bf215546Sopenharmony_ci struct pipe_video_buffer *target; 284bf215546Sopenharmony_ci union { 285bf215546Sopenharmony_ci struct pipe_picture_desc base; 286bf215546Sopenharmony_ci struct pipe_mpeg12_picture_desc mpeg12; 287bf215546Sopenharmony_ci struct pipe_mpeg4_picture_desc mpeg4; 288bf215546Sopenharmony_ci struct pipe_vc1_picture_desc vc1; 289bf215546Sopenharmony_ci struct pipe_h264_picture_desc h264; 290bf215546Sopenharmony_ci struct pipe_h265_picture_desc h265; 291bf215546Sopenharmony_ci struct pipe_mjpeg_picture_desc mjpeg; 292bf215546Sopenharmony_ci struct pipe_vp9_picture_desc vp9; 293bf215546Sopenharmony_ci struct pipe_av1_picture_desc av1; 294bf215546Sopenharmony_ci struct pipe_h264_enc_picture_desc h264enc; 295bf215546Sopenharmony_ci struct pipe_h265_enc_picture_desc h265enc; 296bf215546Sopenharmony_ci struct pipe_vpp_desc vidproc; 297bf215546Sopenharmony_ci } desc; 298bf215546Sopenharmony_ci 299bf215546Sopenharmony_ci struct { 300bf215546Sopenharmony_ci unsigned long long int frame_num; 301bf215546Sopenharmony_ci unsigned int start_code_size; 302bf215546Sopenharmony_ci unsigned int vti_bits; 303bf215546Sopenharmony_ci unsigned int quant_scale; 304bf215546Sopenharmony_ci VAPictureParameterBufferMPEG4 pps; 305bf215546Sopenharmony_ci uint8_t start_code[32]; 306bf215546Sopenharmony_ci } mpeg4; 307bf215546Sopenharmony_ci 308bf215546Sopenharmony_ci struct { 309bf215546Sopenharmony_ci unsigned sampling_factor; 310bf215546Sopenharmony_ci uint8_t slice_header[MAX_MJPEG_SLICE_HEADER_SIZE]; 311bf215546Sopenharmony_ci unsigned int slice_header_size; 312bf215546Sopenharmony_ci } mjpeg; 313bf215546Sopenharmony_ci 314bf215546Sopenharmony_ci struct h264_private h264; 315bf215546Sopenharmony_ci struct vl_deint_filter *deint; 316bf215546Sopenharmony_ci vlVaBuffer *coded_buf; 317bf215546Sopenharmony_ci int target_id; 318bf215546Sopenharmony_ci bool first_single_submitted; 319bf215546Sopenharmony_ci int gop_coeff; 320bf215546Sopenharmony_ci bool needs_begin_frame; 321bf215546Sopenharmony_ci bool vpp_needs_flush_on_endpic; 322bf215546Sopenharmony_ci void *blit_cs; 323bf215546Sopenharmony_ci int packed_header_type; 324bf215546Sopenharmony_ci} vlVaContext; 325bf215546Sopenharmony_ci 326bf215546Sopenharmony_citypedef struct { 327bf215546Sopenharmony_ci enum pipe_video_profile profile; 328bf215546Sopenharmony_ci enum pipe_video_entrypoint entrypoint; 329bf215546Sopenharmony_ci enum pipe_h2645_enc_rate_control_method rc; 330bf215546Sopenharmony_ci unsigned int rt_format; 331bf215546Sopenharmony_ci} vlVaConfig; 332bf215546Sopenharmony_ci 333bf215546Sopenharmony_citypedef struct { 334bf215546Sopenharmony_ci struct pipe_video_buffer templat, *buffer; 335bf215546Sopenharmony_ci struct util_dynarray subpics; /* vlVaSubpicture */ 336bf215546Sopenharmony_ci VAContextID ctx; 337bf215546Sopenharmony_ci vlVaBuffer *coded_buf; 338bf215546Sopenharmony_ci void *feedback; 339bf215546Sopenharmony_ci unsigned int frame_num_cnt; 340bf215546Sopenharmony_ci bool force_flushed; 341bf215546Sopenharmony_ci struct pipe_video_buffer *obsolete_buf; 342bf215546Sopenharmony_ci enum pipe_format encoder_format; 343bf215546Sopenharmony_ci} vlVaSurface; 344bf215546Sopenharmony_ci 345bf215546Sopenharmony_ci// Public functions: 346bf215546Sopenharmony_ciVAStatus VA_DRIVER_INIT_FUNC(VADriverContextP ctx); 347bf215546Sopenharmony_ci 348bf215546Sopenharmony_ci// vtable functions: 349bf215546Sopenharmony_ciVAStatus vlVaTerminate(VADriverContextP ctx); 350bf215546Sopenharmony_ciVAStatus vlVaQueryConfigProfiles(VADriverContextP ctx, VAProfile *profile_list,int *num_profiles); 351bf215546Sopenharmony_ciVAStatus vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile profile, 352bf215546Sopenharmony_ci VAEntrypoint *entrypoint_list, int *num_entrypoints); 353bf215546Sopenharmony_ciVAStatus vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, 354bf215546Sopenharmony_ci VAConfigAttrib *attrib_list, int num_attribs); 355bf215546Sopenharmony_ciVAStatus vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, 356bf215546Sopenharmony_ci VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id); 357bf215546Sopenharmony_ciVAStatus vlVaDestroyConfig(VADriverContextP ctx, VAConfigID config_id); 358bf215546Sopenharmony_ciVAStatus vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, VAProfile *profile, 359bf215546Sopenharmony_ci VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs); 360bf215546Sopenharmony_ciVAStatus vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format, 361bf215546Sopenharmony_ci int num_surfaces, VASurfaceID *surfaces); 362bf215546Sopenharmony_ciVAStatus vlVaDestroySurfaces(VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces); 363bf215546Sopenharmony_ciVAStatus vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, int picture_height, 364bf215546Sopenharmony_ci int flag, VASurfaceID *render_targets, int num_render_targets, VAContextID *context); 365bf215546Sopenharmony_ciVAStatus vlVaDestroyContext(VADriverContextP ctx, VAContextID context); 366bf215546Sopenharmony_ciVAStatus vlVaCreateBuffer(VADriverContextP ctx, VAContextID context, VABufferType type, unsigned int size, 367bf215546Sopenharmony_ci unsigned int num_elements, void *data, VABufferID *buf_id); 368bf215546Sopenharmony_ciVAStatus vlVaBufferSetNumElements(VADriverContextP ctx, VABufferID buf_id, unsigned int num_elements); 369bf215546Sopenharmony_ciVAStatus vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuf); 370bf215546Sopenharmony_ciVAStatus vlVaUnmapBuffer(VADriverContextP ctx, VABufferID buf_id); 371bf215546Sopenharmony_ciVAStatus vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buffer_id); 372bf215546Sopenharmony_ciVAStatus vlVaBeginPicture(VADriverContextP ctx, VAContextID context, VASurfaceID render_target); 373bf215546Sopenharmony_ciVAStatus vlVaRenderPicture(VADriverContextP ctx, VAContextID context, VABufferID *buffers, int num_buffers); 374bf215546Sopenharmony_ciVAStatus vlVaEndPicture(VADriverContextP ctx, VAContextID context); 375bf215546Sopenharmony_ciVAStatus vlVaSyncSurface(VADriverContextP ctx, VASurfaceID render_target); 376bf215546Sopenharmony_ciVAStatus vlVaQuerySurfaceStatus(VADriverContextP ctx, VASurfaceID render_target, VASurfaceStatus *status); 377bf215546Sopenharmony_ciVAStatus vlVaQuerySurfaceError(VADriverContextP ctx, VASurfaceID render_target, 378bf215546Sopenharmony_ci VAStatus error_status, void **error_info); 379bf215546Sopenharmony_ciVAStatus vlVaPutSurface(VADriverContextP ctx, VASurfaceID surface, void* draw, short srcx, short srcy, 380bf215546Sopenharmony_ci unsigned short srcw, unsigned short srch, short destx, short desty, unsigned short destw, 381bf215546Sopenharmony_ci unsigned short desth, VARectangle *cliprects, unsigned int number_cliprects, 382bf215546Sopenharmony_ci unsigned int flags); 383bf215546Sopenharmony_ciVAStatus vlVaQueryImageFormats(VADriverContextP ctx, VAImageFormat *format_list, int *num_formats); 384bf215546Sopenharmony_ciVAStatus vlVaQuerySubpictureFormats(VADriverContextP ctx, VAImageFormat *format_list, 385bf215546Sopenharmony_ci unsigned int *flags, unsigned int *num_formats); 386bf215546Sopenharmony_ciVAStatus vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int height, VAImage *image); 387bf215546Sopenharmony_ciVAStatus vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image); 388bf215546Sopenharmony_ciVAStatus vlVaDestroyImage(VADriverContextP ctx, VAImageID image); 389bf215546Sopenharmony_ciVAStatus vlVaSetImagePalette(VADriverContextP ctx, VAImageID image, unsigned char *palette); 390bf215546Sopenharmony_ciVAStatus vlVaGetImage(VADriverContextP ctx, VASurfaceID surface, int x, int y, 391bf215546Sopenharmony_ci unsigned int width, unsigned int height, VAImageID image); 392bf215546Sopenharmony_ciVAStatus vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image, int src_x, int src_y, 393bf215546Sopenharmony_ci unsigned int src_width, unsigned int src_height, int dest_x, int dest_y, 394bf215546Sopenharmony_ci unsigned int dest_width, unsigned int dest_height); 395bf215546Sopenharmony_ciVAStatus vlVaQuerySubpictureFormats(VADriverContextP ctx, VAImageFormat *format_list, 396bf215546Sopenharmony_ci unsigned int *flags, unsigned int *num_formats); 397bf215546Sopenharmony_ciVAStatus vlVaCreateSubpicture(VADriverContextP ctx, VAImageID image, VASubpictureID *subpicture); 398bf215546Sopenharmony_ciVAStatus vlVaDestroySubpicture(VADriverContextP ctx, VASubpictureID subpicture); 399bf215546Sopenharmony_ciVAStatus vlVaSubpictureImage(VADriverContextP ctx, VASubpictureID subpicture, VAImageID image); 400bf215546Sopenharmony_ciVAStatus vlVaSetSubpictureChromakey(VADriverContextP ctx, VASubpictureID subpicture, 401bf215546Sopenharmony_ci unsigned int chromakey_min, unsigned int chromakey_max, 402bf215546Sopenharmony_ci unsigned int chromakey_mask); 403bf215546Sopenharmony_ciVAStatus vlVaSetSubpictureGlobalAlpha(VADriverContextP ctx, VASubpictureID subpicture, float global_alpha); 404bf215546Sopenharmony_ciVAStatus vlVaAssociateSubpicture(VADriverContextP ctx, VASubpictureID subpicture, VASurfaceID *target_surfaces, 405bf215546Sopenharmony_ci int num_surfaces, short src_x, short src_y, 406bf215546Sopenharmony_ci unsigned short src_width, unsigned short src_height, 407bf215546Sopenharmony_ci short dest_x, short dest_y, unsigned short dest_width, unsigned short dest_height, 408bf215546Sopenharmony_ci unsigned int flags); 409bf215546Sopenharmony_ciVAStatus vlVaDeassociateSubpicture(VADriverContextP ctx, VASubpictureID subpicture, 410bf215546Sopenharmony_ci VASurfaceID *target_surfaces, int num_surfaces); 411bf215546Sopenharmony_ciVAStatus vlVaQueryDisplayAttributes(VADriverContextP ctx, VADisplayAttribute *attr_list, int *num_attributes); 412bf215546Sopenharmony_ciVAStatus vlVaGetDisplayAttributes(VADriverContextP ctx, VADisplayAttribute *attr_list, int num_attributes); 413bf215546Sopenharmony_ciVAStatus vlVaSetDisplayAttributes(VADriverContextP ctx, VADisplayAttribute *attr_list, int num_attributes); 414bf215546Sopenharmony_ciVAStatus vlVaBufferInfo(VADriverContextP ctx, VABufferID buf_id, VABufferType *type, 415bf215546Sopenharmony_ci unsigned int *size, unsigned int *num_elements); 416bf215546Sopenharmony_ciVAStatus vlVaLockSurface(VADriverContextP ctx, VASurfaceID surface, unsigned int *fourcc, 417bf215546Sopenharmony_ci unsigned int *luma_stride, unsigned int *chroma_u_stride, unsigned int *chroma_v_stride, 418bf215546Sopenharmony_ci unsigned int *luma_offset, unsigned int *chroma_u_offset, unsigned int *chroma_v_offset, 419bf215546Sopenharmony_ci unsigned int *buffer_name, void **buffer); 420bf215546Sopenharmony_ciVAStatus vlVaUnlockSurface(VADriverContextP ctx, VASurfaceID surface); 421bf215546Sopenharmony_ciVAStatus vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, unsigned int width, unsigned int height, 422bf215546Sopenharmony_ci VASurfaceID *surfaces, unsigned int num_surfaces, VASurfaceAttrib *attrib_list, 423bf215546Sopenharmony_ci unsigned int num_attribs); 424bf215546Sopenharmony_ciVAStatus vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, VASurfaceAttrib *attrib_list, 425bf215546Sopenharmony_ci unsigned int *num_attribs); 426bf215546Sopenharmony_ci 427bf215546Sopenharmony_ciVAStatus vlVaAcquireBufferHandle(VADriverContextP ctx, VABufferID buf_id, VABufferInfo *out_buf_info); 428bf215546Sopenharmony_ciVAStatus vlVaReleaseBufferHandle(VADriverContextP ctx, VABufferID buf_id); 429bf215546Sopenharmony_ciVAStatus vlVaExportSurfaceHandle(VADriverContextP ctx, VASurfaceID surface_id, uint32_t mem_type, uint32_t flags, void *descriptor); 430bf215546Sopenharmony_ci 431bf215546Sopenharmony_ciVAStatus vlVaQueryVideoProcFilters(VADriverContextP ctx, VAContextID context, VAProcFilterType *filters, 432bf215546Sopenharmony_ci unsigned int *num_filters); 433bf215546Sopenharmony_ciVAStatus vlVaQueryVideoProcFilterCaps(VADriverContextP ctx, VAContextID context, VAProcFilterType type, 434bf215546Sopenharmony_ci void *filter_caps, unsigned int *num_filter_caps); 435bf215546Sopenharmony_ciVAStatus vlVaQueryVideoProcPipelineCaps(VADriverContextP ctx, VAContextID context, VABufferID *filters, 436bf215546Sopenharmony_ci unsigned int num_filters, VAProcPipelineCaps *pipeline_cap); 437bf215546Sopenharmony_ci 438bf215546Sopenharmony_ci// internal functions 439bf215546Sopenharmony_ciVAStatus vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); 440bf215546Sopenharmony_ciVAStatus vlVaHandleSurfaceAllocate(vlVaDriver *drv, vlVaSurface *surface, struct pipe_video_buffer *templat, 441bf215546Sopenharmony_ci const uint64_t *modifiers, unsigned int modifiers_count); 442bf215546Sopenharmony_civoid vlVaGetReferenceFrame(vlVaDriver *drv, VASurfaceID surface_id, struct pipe_video_buffer **ref_frame); 443bf215546Sopenharmony_civoid vlVaHandlePictureParameterBufferMPEG12(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); 444bf215546Sopenharmony_civoid vlVaHandleIQMatrixBufferMPEG12(vlVaContext *context, vlVaBuffer *buf); 445bf215546Sopenharmony_civoid vlVaHandleSliceParameterBufferMPEG12(vlVaContext *context, vlVaBuffer *buf); 446bf215546Sopenharmony_civoid vlVaHandlePictureParameterBufferH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); 447bf215546Sopenharmony_civoid vlVaHandleIQMatrixBufferH264(vlVaContext *context, vlVaBuffer *buf); 448bf215546Sopenharmony_civoid vlVaHandleSliceParameterBufferH264(vlVaContext *context, vlVaBuffer *buf); 449bf215546Sopenharmony_civoid vlVaHandlePictureParameterBufferVC1(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); 450bf215546Sopenharmony_civoid vlVaHandleSliceParameterBufferVC1(vlVaContext *context, vlVaBuffer *buf); 451bf215546Sopenharmony_civoid vlVaHandlePictureParameterBufferMPEG4(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); 452bf215546Sopenharmony_civoid vlVaHandleIQMatrixBufferMPEG4(vlVaContext *context, vlVaBuffer *buf); 453bf215546Sopenharmony_civoid vlVaHandleSliceParameterBufferMPEG4(vlVaContext *context, vlVaBuffer *buf); 454bf215546Sopenharmony_civoid vlVaDecoderFixMPEG4Startcode(vlVaContext *context); 455bf215546Sopenharmony_civoid vlVaGetJpegSliceHeader(vlVaContext *context); 456bf215546Sopenharmony_civoid vlVaHandlePictureParameterBufferHEVC(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); 457bf215546Sopenharmony_civoid vlVaHandleIQMatrixBufferHEVC(vlVaContext *context, vlVaBuffer *buf); 458bf215546Sopenharmony_civoid vlVaHandleSliceParameterBufferHEVC(vlVaContext *context, vlVaBuffer *buf); 459bf215546Sopenharmony_civoid vlVaHandlePictureParameterBufferMJPEG(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); 460bf215546Sopenharmony_civoid vlVaHandleIQMatrixBufferMJPEG(vlVaContext *context, vlVaBuffer *buf); 461bf215546Sopenharmony_civoid vlVaHandleHuffmanTableBufferType(vlVaContext *context, vlVaBuffer *buf); 462bf215546Sopenharmony_civoid vlVaHandleSliceParameterBufferMJPEG(vlVaContext *context, vlVaBuffer *buf); 463bf215546Sopenharmony_civoid vlVaHandlePictureParameterBufferVP9(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); 464bf215546Sopenharmony_civoid vlVaHandleSliceParameterBufferVP9(vlVaContext *context, vlVaBuffer *buf); 465bf215546Sopenharmony_civoid vlVaDecoderVP9BitstreamHeader(vlVaContext *context, vlVaBuffer *buf); 466bf215546Sopenharmony_civoid vlVaHandlePictureParameterBufferAV1(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); 467bf215546Sopenharmony_civoid vlVaHandleSliceParameterBufferAV1(vlVaContext *context, vlVaBuffer *buf, unsigned int num); 468bf215546Sopenharmony_civoid getEncParamPresetH264(vlVaContext *context); 469bf215546Sopenharmony_civoid getEncParamPresetH265(vlVaContext *context); 470bf215546Sopenharmony_ciVAStatus vlVaHandleVAEncPictureParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); 471bf215546Sopenharmony_ciVAStatus vlVaHandleVAEncSliceParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); 472bf215546Sopenharmony_ciVAStatus vlVaHandleVAEncSequenceParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); 473bf215546Sopenharmony_ciVAStatus vlVaHandleVAEncMiscParameterTypeRateControlH264(vlVaContext *context, VAEncMiscParameterBuffer *buf); 474bf215546Sopenharmony_ciVAStatus vlVaHandleVAEncMiscParameterTypeFrameRateH264(vlVaContext *context, VAEncMiscParameterBuffer *buf); 475bf215546Sopenharmony_ciVAStatus vlVaHandleVAEncMiscParameterTypeTemporalLayerH264(vlVaContext *context, VAEncMiscParameterBuffer *buf); 476bf215546Sopenharmony_ciVAStatus vlVaHandleVAEncPictureParameterBufferTypeHEVC(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); 477bf215546Sopenharmony_ciVAStatus vlVaHandleVAEncSliceParameterBufferTypeHEVC(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); 478bf215546Sopenharmony_ciVAStatus vlVaHandleVAEncSequenceParameterBufferTypeHEVC(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); 479bf215546Sopenharmony_ciVAStatus vlVaHandleVAEncMiscParameterTypeRateControlHEVC(vlVaContext *context, VAEncMiscParameterBuffer *buf); 480bf215546Sopenharmony_ciVAStatus vlVaHandleVAEncMiscParameterTypeFrameRateHEVC(vlVaContext *context, VAEncMiscParameterBuffer *buf); 481bf215546Sopenharmony_ciVAStatus vlVaHandleVAEncPackedHeaderDataBufferTypeHEVC(vlVaContext *context, vlVaBuffer *buf); 482bf215546Sopenharmony_ci#endif //VA_PRIVATE_H 483