vdpau_private.h revision 28f8ff6b622d63e8ffe322ab2cdf5197941f1a40
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_decoder.h" 38 39#include "util/u_debug.h" 40#include "vl/vl_compositor.h" 41 42#include "vl_winsys.h" 43 44#define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR 45#define QUOTEME(x) #x 46#define TOSTRING(x) QUOTEME(x) 47#define INFORMATION_STRING TOSTRING(INFORMATION) 48#define VL_HANDLES 49 50static inline enum pipe_video_chroma_format 51ChromaToPipe(VdpChromaType vdpau_type) 52{ 53 switch (vdpau_type) { 54 case VDP_CHROMA_TYPE_420: 55 return PIPE_VIDEO_CHROMA_FORMAT_420; 56 case VDP_CHROMA_TYPE_422: 57 return PIPE_VIDEO_CHROMA_FORMAT_422; 58 case VDP_CHROMA_TYPE_444: 59 return PIPE_VIDEO_CHROMA_FORMAT_444; 60 default: 61 assert(0); 62 } 63 64 return -1; 65} 66 67static inline VdpChromaType 68PipeToChroma(enum pipe_video_chroma_format pipe_type) 69{ 70 switch (pipe_type) { 71 case PIPE_VIDEO_CHROMA_FORMAT_420: 72 return VDP_CHROMA_TYPE_420; 73 case PIPE_VIDEO_CHROMA_FORMAT_422: 74 return VDP_CHROMA_TYPE_422; 75 case PIPE_VIDEO_CHROMA_FORMAT_444: 76 return VDP_CHROMA_TYPE_444; 77 default: 78 assert(0); 79 } 80 81 return -1; 82} 83 84 85static inline enum pipe_format 86FormatYCBCRToPipe(VdpYCbCrFormat vdpau_format) 87{ 88 switch (vdpau_format) { 89 case VDP_YCBCR_FORMAT_NV12: 90 return PIPE_FORMAT_NV12; 91 case VDP_YCBCR_FORMAT_YV12: 92 return PIPE_FORMAT_YV12; 93 case VDP_YCBCR_FORMAT_UYVY: 94 return PIPE_FORMAT_UYVY; 95 case VDP_YCBCR_FORMAT_YUYV: 96 return PIPE_FORMAT_YUYV; 97 case VDP_YCBCR_FORMAT_Y8U8V8A8: /* Not defined in p_format.h */ 98 return 0; 99 case VDP_YCBCR_FORMAT_V8U8Y8A8: 100 return PIPE_FORMAT_VUYA; 101 default: 102 assert(0); 103 } 104 105 return -1; 106} 107 108static inline VdpYCbCrFormat 109PipeToFormatYCBCR(enum pipe_format p_format) 110{ 111 switch (p_format) { 112 case PIPE_FORMAT_NV12: 113 return VDP_YCBCR_FORMAT_NV12; 114 case PIPE_FORMAT_YV12: 115 return VDP_YCBCR_FORMAT_YV12; 116 case PIPE_FORMAT_UYVY: 117 return VDP_YCBCR_FORMAT_UYVY; 118 case PIPE_FORMAT_YUYV: 119 return VDP_YCBCR_FORMAT_YUYV; 120 //case PIPE_FORMAT_YUVA: 121 // return VDP_YCBCR_FORMAT_Y8U8V8A8; 122 case PIPE_FORMAT_VUYA: 123 return VDP_YCBCR_FORMAT_V8U8Y8A8; 124 default: 125 assert(0); 126 } 127 128 return -1; 129} 130 131static inline enum pipe_format 132FormatRGBAToPipe(VdpRGBAFormat vdpau_format) 133{ 134 switch (vdpau_format) { 135 case VDP_RGBA_FORMAT_A8: 136 return PIPE_FORMAT_A8_UNORM; 137 case VDP_RGBA_FORMAT_B10G10R10A2: 138 return PIPE_FORMAT_B10G10R10A2_UNORM; 139 case VDP_RGBA_FORMAT_B8G8R8A8: 140 return PIPE_FORMAT_B8G8R8A8_UNORM; 141 case VDP_RGBA_FORMAT_R10G10B10A2: 142 return PIPE_FORMAT_R10G10B10A2_UNORM; 143 case VDP_RGBA_FORMAT_R8G8B8A8: 144 return PIPE_FORMAT_R8G8B8A8_UNORM; 145 default: 146 assert(0); 147 } 148 149 return -1; 150} 151 152static inline VdpRGBAFormat 153PipeToFormatRGBA(enum pipe_format p_format) 154{ 155 switch (p_format) { 156 case PIPE_FORMAT_A8_UNORM: 157 return VDP_RGBA_FORMAT_A8; 158 case PIPE_FORMAT_B10G10R10A2_UNORM: 159 return VDP_RGBA_FORMAT_B10G10R10A2; 160 case PIPE_FORMAT_B8G8R8A8_UNORM: 161 return VDP_RGBA_FORMAT_B8G8R8A8; 162 case PIPE_FORMAT_R10G10B10A2_UNORM: 163 return VDP_RGBA_FORMAT_R10G10B10A2; 164 case PIPE_FORMAT_R8G8B8A8_UNORM: 165 return VDP_RGBA_FORMAT_R8G8B8A8; 166 default: 167 assert(0); 168 } 169 170 return -1; 171} 172 173static inline enum pipe_video_profile 174ProfileToPipe(VdpDecoderProfile vdpau_profile) 175{ 176 switch (vdpau_profile) { 177 case VDP_DECODER_PROFILE_MPEG1: 178 return PIPE_VIDEO_PROFILE_MPEG1; 179 case VDP_DECODER_PROFILE_MPEG2_SIMPLE: 180 return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE; 181 case VDP_DECODER_PROFILE_MPEG2_MAIN: 182 return PIPE_VIDEO_PROFILE_MPEG2_MAIN; 183 case VDP_DECODER_PROFILE_H264_BASELINE: 184 return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE; 185 case VDP_DECODER_PROFILE_H264_MAIN: /* Not defined in p_format.h */ 186 return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN; 187 case VDP_DECODER_PROFILE_H264_HIGH: 188 return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH; 189 default: 190 return PIPE_VIDEO_PROFILE_UNKNOWN; 191 } 192} 193 194static inline VdpDecoderProfile 195PipeToProfile(enum pipe_video_profile p_profile) 196{ 197 switch (p_profile) { 198 case PIPE_VIDEO_PROFILE_MPEG1: 199 return VDP_DECODER_PROFILE_MPEG1; 200 case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE: 201 return VDP_DECODER_PROFILE_MPEG2_SIMPLE; 202 case PIPE_VIDEO_PROFILE_MPEG2_MAIN: 203 return VDP_DECODER_PROFILE_MPEG2_MAIN; 204 case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE: 205 return VDP_DECODER_PROFILE_H264_BASELINE; 206 case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN: /* Not defined in p_format.h */ 207 return VDP_DECODER_PROFILE_H264_MAIN; 208 case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH: 209 return VDP_DECODER_PROFILE_H264_HIGH; 210 default: 211 assert(0); 212 return -1; 213 } 214} 215 216typedef struct 217{ 218 struct vl_screen *vscreen; 219 struct vl_context *context; 220} vlVdpDevice; 221 222typedef struct 223{ 224 vlVdpDevice *device; 225 Drawable drawable; 226} vlVdpPresentationQueueTarget; 227 228typedef struct 229{ 230 vlVdpDevice *device; 231 Drawable drawable; 232 struct vl_compositor compositor; 233} vlVdpPresentationQueue; 234 235typedef struct 236{ 237 vlVdpDevice *device; 238 struct vl_compositor compositor; 239} vlVdpVideoMixer; 240 241typedef struct 242{ 243 vlVdpDevice *device; 244 struct pipe_video_buffer *video_buffer; 245} vlVdpSurface; 246 247typedef struct 248{ 249 vlVdpDevice *device; 250 struct pipe_surface *surface; 251 struct pipe_sampler_view *sampler_view; 252} vlVdpOutputSurface; 253 254typedef struct 255{ 256 vlVdpDevice *device; 257 struct pipe_video_decoder *decoder; 258 unsigned num_buffers; 259 void **buffers; 260 unsigned cur_buffer; 261} vlVdpDecoder; 262 263typedef uint32_t vlHandle; 264 265boolean vlCreateHTAB(void); 266void vlDestroyHTAB(void); 267vlHandle vlAddDataHTAB(void *data); 268void* vlGetDataHTAB(vlHandle handle); 269void vlRemoveDataHTAB(vlHandle handle); 270 271boolean vlGetFuncFTAB(VdpFuncId function_id, void **func); 272 273/* Public functions */ 274VdpDeviceCreateX11 vdp_imp_device_create_x11; 275VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11; 276 277/* Internal function pointers */ 278VdpGetErrorString vlVdpGetErrorString; 279VdpDeviceDestroy vlVdpDeviceDestroy; 280VdpGetProcAddress vlVdpGetProcAddress; 281VdpGetApiVersion vlVdpGetApiVersion; 282VdpGetInformationString vlVdpGetInformationString; 283VdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities; 284VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities; 285VdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities; 286VdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities; 287VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities; 288VdpOutputSurfaceQueryPutBitsIndexedCapabilities vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities; 289VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities; 290VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities; 291VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport; 292VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport; 293VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange; 294VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport; 295VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange; 296VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate; 297VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy; 298VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters; 299VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr; 300VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr; 301VdpDecoderCreate vlVdpDecoderCreate; 302VdpDecoderDestroy vlVdpDecoderDestroy; 303VdpDecoderGetParameters vlVdpDecoderGetParameters; 304VdpDecoderRender vlVdpDecoderRender; 305VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate; 306VdpOutputSurfaceDestroy vlVdpOutputSurfaceDestroy; 307VdpOutputSurfaceGetParameters vlVdpOutputSurfaceGetParameters; 308VdpOutputSurfaceGetBitsNative vlVdpOutputSurfaceGetBitsNative; 309VdpOutputSurfacePutBitsNative vlVdpOutputSurfacePutBitsNative; 310VdpOutputSurfacePutBitsIndexed vlVdpOutputSurfacePutBitsIndexed; 311VdpOutputSurfacePutBitsYCbCr vlVdpOutputSurfacePutBitsYCbCr; 312VdpOutputSurfaceRenderOutputSurface vlVdpOutputSurfaceRenderOutputSurface; 313VdpOutputSurfaceRenderBitmapSurface vlVdpOutputSurfaceRenderBitmapSurface; 314VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate; 315VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy; 316VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters; 317VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative; 318VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy; 319VdpPresentationQueueCreate vlVdpPresentationQueueCreate; 320VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy; 321VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor; 322VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor; 323VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime; 324VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay; 325VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle; 326VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus; 327VdpPreemptionCallback vlVdpPreemptionCallback; 328VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister; 329VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables; 330VdpVideoMixerCreate vlVdpVideoMixerCreate; 331VdpVideoMixerRender vlVdpVideoMixerRender; 332VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues; 333VdpVideoMixerGetFeatureSupport vlVdpVideoMixerGetFeatureSupport; 334VdpVideoMixerGetFeatureEnables vlVdpVideoMixerGetFeatureEnables; 335VdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues; 336VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues; 337VdpVideoMixerDestroy vlVdpVideoMixerDestroy; 338VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix; 339 340#define VDPAU_OUT 0 341#define VDPAU_ERR 1 342#define VDPAU_WARN 2 343#define VDPAU_TRACE 3 344 345static inline void VDPAU_MSG(unsigned int level, const char *fmt, ...) 346{ 347 static int debug_level = -1; 348 349 if (debug_level == -1) { 350 debug_level = MAX2(debug_get_num_option("VDPAU_DEBUG", 0), 0); 351 } 352 353 if (level <= debug_level) { 354 va_list ap; 355 va_start(ap, fmt); 356 _debug_vprintf(fmt, ap); 357 va_end(ap); 358 } 359} 360 361#endif // VDPAU_PRIVATE_H 362