vdpau_private.h revision 08f3a7cf7e9133f50adf33f800aa3696c909347f
1/************************************************************************** 2 * 3 * Copyright 2010 Younes Manton & Thomas Balling Sørensen. 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sub license, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 **************************************************************************/ 27 28#ifndef VDPAU_PRIVATE_H 29#define VDPAU_PRIVATE_H 30 31#include <assert.h> 32 33#include <vdpau/vdpau.h> 34#include <vdpau/vdpau_x11.h> 35 36#include <pipe/p_compiler.h> 37#include <pipe/p_video_context.h> 38 39#include <util/u_debug.h> 40 41#include <vl_winsys.h> 42 43#define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR 44#define QUOTEME(x) #x 45#define TOSTRING(x) QUOTEME(x) 46#define INFORMATION_STRING TOSTRING(INFORMATION) 47#define VL_HANDLES 48 49static inline enum pipe_video_chroma_format 50ChromaToPipe(VdpChromaType vdpau_type) 51{ 52 switch (vdpau_type) { 53 case VDP_CHROMA_TYPE_420: 54 return PIPE_VIDEO_CHROMA_FORMAT_420; 55 case VDP_CHROMA_TYPE_422: 56 return PIPE_VIDEO_CHROMA_FORMAT_422; 57 case VDP_CHROMA_TYPE_444: 58 return PIPE_VIDEO_CHROMA_FORMAT_444; 59 default: 60 assert(0); 61 } 62 63 return -1; 64} 65 66static inline VdpChromaType 67PipeToChroma(enum pipe_video_chroma_format pipe_type) 68{ 69 switch (pipe_type) { 70 case PIPE_VIDEO_CHROMA_FORMAT_420: 71 return VDP_CHROMA_TYPE_420; 72 case PIPE_VIDEO_CHROMA_FORMAT_422: 73 return VDP_CHROMA_TYPE_422; 74 case PIPE_VIDEO_CHROMA_FORMAT_444: 75 return VDP_CHROMA_TYPE_444; 76 default: 77 assert(0); 78 } 79 80 return -1; 81} 82 83 84static inline enum pipe_format 85FormatToPipe(VdpYCbCrFormat vdpau_format) 86{ 87 switch (vdpau_format) { 88 case VDP_YCBCR_FORMAT_NV12: 89 return PIPE_FORMAT_NV12; 90 case VDP_YCBCR_FORMAT_YV12: 91 return PIPE_FORMAT_YV12; 92 case VDP_YCBCR_FORMAT_UYVY: 93 return PIPE_FORMAT_UYVY; 94 case VDP_YCBCR_FORMAT_YUYV: 95 return PIPE_FORMAT_YUYV; 96 case VDP_YCBCR_FORMAT_Y8U8V8A8: /* Not defined in p_format.h */ 97 return 0; 98 case VDP_YCBCR_FORMAT_V8U8Y8A8: 99 return PIPE_FORMAT_VUYA; 100 default: 101 assert(0); 102 } 103 104 return -1; 105} 106 107static inline enum pipe_format 108FormatRGBAToPipe(VdpRGBAFormat vdpau_format) 109{ 110 switch (vdpau_format) { 111 case VDP_RGBA_FORMAT_A8: 112 return PIPE_FORMAT_A8_UNORM; 113 case VDP_RGBA_FORMAT_B10G10R10A2: 114 return PIPE_FORMAT_B10G10R10A2_UNORM; 115 case VDP_RGBA_FORMAT_B8G8R8A8: 116 return PIPE_FORMAT_B8G8R8A8_UNORM; 117 case VDP_RGBA_FORMAT_R10G10B10A2: 118 return PIPE_FORMAT_R10G10B10A2_UNORM; 119 case VDP_RGBA_FORMAT_R8G8B8A8: 120 return PIPE_FORMAT_R8G8B8A8_UNORM; 121 default: 122 assert(0); 123 } 124 125 return -1; 126} 127 128static inline VdpYCbCrFormat 129PipeToFormat(enum pipe_format p_format) 130{ 131 switch (p_format) { 132 case PIPE_FORMAT_NV12: 133 return VDP_YCBCR_FORMAT_NV12; 134 case PIPE_FORMAT_YV12: 135 return VDP_YCBCR_FORMAT_YV12; 136 case PIPE_FORMAT_UYVY: 137 return VDP_YCBCR_FORMAT_UYVY; 138 case PIPE_FORMAT_YUYV: 139 return VDP_YCBCR_FORMAT_YUYV; 140 //case PIPE_FORMAT_YUVA: 141 // return VDP_YCBCR_FORMAT_Y8U8V8A8; 142 case PIPE_FORMAT_VUYA: 143 return VDP_YCBCR_FORMAT_V8U8Y8A8; 144 default: 145 assert(0); 146 } 147 148 return -1; 149} 150 151static inline enum pipe_video_profile 152ProfileToPipe(VdpDecoderProfile vdpau_profile) 153{ 154 switch (vdpau_profile) { 155 case VDP_DECODER_PROFILE_MPEG1: 156 return PIPE_VIDEO_PROFILE_MPEG1; 157 case VDP_DECODER_PROFILE_MPEG2_SIMPLE: 158 return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE; 159 case VDP_DECODER_PROFILE_MPEG2_MAIN: 160 return PIPE_VIDEO_PROFILE_MPEG2_MAIN; 161 case VDP_DECODER_PROFILE_H264_BASELINE: 162 return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE; 163 case VDP_DECODER_PROFILE_H264_MAIN: /* Not defined in p_format.h */ 164 return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN; 165 case VDP_DECODER_PROFILE_H264_HIGH: 166 return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH; 167 default: 168 return PIPE_VIDEO_PROFILE_UNKNOWN; 169 } 170} 171 172typedef struct 173{ 174 Display *display; 175 int screen; 176 struct vl_screen *vscreen; 177 struct vl_context *context; 178} vlVdpDevice; 179 180typedef struct 181{ 182 vlVdpDevice *device; 183 Drawable drawable; 184} vlVdpPresentationQueueTarget; 185 186typedef struct 187{ 188 vlVdpDevice *device; 189 Drawable drawable; 190 struct pipe_video_compositor *compositor; 191} vlVdpPresentationQueue; 192 193typedef struct 194{ 195 vlVdpDevice *device; 196 struct pipe_video_compositor *compositor; 197} vlVdpVideoMixer; 198 199typedef struct 200{ 201 vlVdpDevice *device; 202 struct pipe_video_buffer *video_buffer; 203} vlVdpSurface; 204 205typedef struct 206{ 207 vlVdpDevice *device; 208 struct pipe_surface *surface; 209 struct pipe_sampler_view *sampler_view; 210} vlVdpOutputSurface; 211 212typedef struct 213{ 214 vlVdpDevice *device; 215 struct pipe_video_decoder *decoder; 216 struct pipe_video_decode_buffer *buffer; 217} vlVdpDecoder; 218 219typedef uint32_t vlHandle; 220 221boolean vlCreateHTAB(void); 222void vlDestroyHTAB(void); 223vlHandle vlAddDataHTAB(void *data); 224void* vlGetDataHTAB(vlHandle handle); 225void vlRemoveDataHTAB(vlHandle handle); 226 227boolean vlGetFuncFTAB(VdpFuncId function_id, void **func); 228 229/* Public functions */ 230VdpDeviceCreateX11 vdp_imp_device_create_x11; 231VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11; 232 233/* Internal function pointers */ 234VdpGetErrorString vlVdpGetErrorString; 235VdpDeviceDestroy vlVdpDeviceDestroy; 236VdpGetProcAddress vlVdpGetProcAddress; 237VdpGetApiVersion vlVdpGetApiVersion; 238VdpGetInformationString vlVdpGetInformationString; 239VdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities; 240VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities; 241VdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities; 242VdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities; 243VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities; 244VdpOutputSurfaceQueryPutBitsIndexedCapabilities vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities; 245VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities; 246VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities; 247VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport; 248VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport; 249VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange; 250VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport; 251VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange; 252VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate; 253VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy; 254VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters; 255VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr; 256VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr; 257VdpDecoderCreate vlVdpDecoderCreate; 258VdpDecoderDestroy vlVdpDecoderDestroy; 259VdpDecoderGetParameters vlVdpDecoderGetParameters; 260VdpDecoderRender vlVdpDecoderRender; 261VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate; 262VdpOutputSurfaceDestroy vlVdpOutputSurfaceDestroy; 263VdpOutputSurfaceGetParameters vlVdpOutputSurfaceGetParameters; 264VdpOutputSurfaceGetBitsNative vlVdpOutputSurfaceGetBitsNative; 265VdpOutputSurfacePutBitsNative vlVdpOutputSurfacePutBitsNative; 266VdpOutputSurfacePutBitsIndexed vlVdpOutputSurfacePutBitsIndexed; 267VdpOutputSurfacePutBitsYCbCr vlVdpOutputSurfacePutBitsYCbCr; 268VdpOutputSurfaceRenderOutputSurface vlVdpOutputSurfaceRenderOutputSurface; 269VdpOutputSurfaceRenderBitmapSurface vlVdpOutputSurfaceRenderBitmapSurface; 270VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate; 271VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy; 272VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters; 273VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative; 274VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy; 275VdpPresentationQueueCreate vlVdpPresentationQueueCreate; 276VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy; 277VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor; 278VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor; 279VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime; 280VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay; 281VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle; 282VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus; 283VdpPreemptionCallback vlVdpPreemptionCallback; 284VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister; 285VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables; 286VdpVideoMixerCreate vlVdpVideoMixerCreate; 287VdpVideoMixerRender vlVdpVideoMixerRender; 288VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues; 289VdpVideoMixerGetFeatureSupport vlVdpVideoMixerGetFeatureSupport; 290VdpVideoMixerGetFeatureEnables vlVdpVideoMixerGetFeatureEnables; 291VdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues; 292VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues; 293VdpVideoMixerDestroy vlVdpVideoMixerDestroy; 294VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix; 295 296#define VDPAU_OUT 0 297#define VDPAU_ERR 1 298#define VDPAU_WARN 2 299#define VDPAU_TRACE 3 300 301static inline void VDPAU_MSG(unsigned int level, const char *fmt, ...) 302{ 303 static int debug_level = -1; 304 305 if (debug_level == -1) { 306 debug_level = MAX2(debug_get_num_option("VDPAU_DEBUG", 0), 0); 307 } 308 309 if (level <= debug_level) { 310 va_list ap; 311 va_start(ap, fmt); 312 _debug_vprintf(fmt, ap); 313 va_end(ap); 314 } 315} 316 317#endif // VDPAU_PRIVATE_H 318