1 /**************************************************************************
3 * Copyright 2010 Younes Manton & Thomas Balling Sørensen.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #ifndef VDPAU_PRIVATE_H
29 #define VDPAU_PRIVATE_H
33 #include <vdpau/vdpau.h>
34 #include <vdpau/vdpau_x11.h>
36 #include "pipe/p_compiler.h"
37 #include "pipe/p_video_decoder.h"
39 #include "util/u_debug.h"
40 #include "vl/vl_compositor.h"
42 #include "vl_winsys.h"
44 /* Full VDPAU API documentation available at :
45 * ftp://download.nvidia.com/XFree86/vdpau/doxygen/html/index.html */
47 #define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR
49 #define TOSTRING(x) QUOTEME(x)
50 #define INFORMATION_STRING TOSTRING(INFORMATION)
53 static inline enum pipe_video_chroma_format
54 ChromaToPipe(VdpChromaType vdpau_type
)
57 case VDP_CHROMA_TYPE_420
:
58 return PIPE_VIDEO_CHROMA_FORMAT_420
;
59 case VDP_CHROMA_TYPE_422
:
60 return PIPE_VIDEO_CHROMA_FORMAT_422
;
61 case VDP_CHROMA_TYPE_444
:
62 return PIPE_VIDEO_CHROMA_FORMAT_444
;
70 static inline VdpChromaType
71 PipeToChroma(enum pipe_video_chroma_format pipe_type
)
74 case PIPE_VIDEO_CHROMA_FORMAT_420
:
75 return VDP_CHROMA_TYPE_420
;
76 case PIPE_VIDEO_CHROMA_FORMAT_422
:
77 return VDP_CHROMA_TYPE_422
;
78 case PIPE_VIDEO_CHROMA_FORMAT_444
:
79 return VDP_CHROMA_TYPE_444
;
87 static inline enum pipe_format
88 FormatYCBCRToPipe(VdpYCbCrFormat vdpau_format
)
90 switch (vdpau_format
) {
91 case VDP_YCBCR_FORMAT_NV12
:
92 return PIPE_FORMAT_NV12
;
93 case VDP_YCBCR_FORMAT_YV12
:
94 return PIPE_FORMAT_YV12
;
95 case VDP_YCBCR_FORMAT_UYVY
:
96 return PIPE_FORMAT_UYVY
;
97 case VDP_YCBCR_FORMAT_YUYV
:
98 return PIPE_FORMAT_YUYV
;
99 case VDP_YCBCR_FORMAT_Y8U8V8A8
: /* Not defined in p_format.h */
100 return PIPE_FORMAT_NONE
;
101 case VDP_YCBCR_FORMAT_V8U8Y8A8
:
102 return PIPE_FORMAT_VUYA
;
107 return PIPE_FORMAT_NONE
;
110 static inline VdpYCbCrFormat
111 PipeToFormatYCBCR(enum pipe_format p_format
)
114 case PIPE_FORMAT_NV12
:
115 return VDP_YCBCR_FORMAT_NV12
;
116 case PIPE_FORMAT_YV12
:
117 return VDP_YCBCR_FORMAT_YV12
;
118 case PIPE_FORMAT_UYVY
:
119 return VDP_YCBCR_FORMAT_UYVY
;
120 case PIPE_FORMAT_YUYV
:
121 return VDP_YCBCR_FORMAT_YUYV
;
122 //case PIPE_FORMAT_YUVA:
123 // return VDP_YCBCR_FORMAT_Y8U8V8A8;
124 case PIPE_FORMAT_VUYA
:
125 return VDP_YCBCR_FORMAT_V8U8Y8A8
;
133 static inline enum pipe_format
134 FormatRGBAToPipe(VdpRGBAFormat vdpau_format
)
136 switch (vdpau_format
) {
137 case VDP_RGBA_FORMAT_A8
:
138 return PIPE_FORMAT_A8_UNORM
;
139 case VDP_RGBA_FORMAT_B10G10R10A2
:
140 return PIPE_FORMAT_B10G10R10A2_UNORM
;
141 case VDP_RGBA_FORMAT_B8G8R8A8
:
142 return PIPE_FORMAT_B8G8R8A8_UNORM
;
143 case VDP_RGBA_FORMAT_R10G10B10A2
:
144 return PIPE_FORMAT_R10G10B10A2_UNORM
;
145 case VDP_RGBA_FORMAT_R8G8B8A8
:
146 return PIPE_FORMAT_R8G8B8A8_UNORM
;
151 return PIPE_FORMAT_NONE
;
154 static inline VdpRGBAFormat
155 PipeToFormatRGBA(enum pipe_format p_format
)
158 case PIPE_FORMAT_A8_UNORM
:
159 return VDP_RGBA_FORMAT_A8
;
160 case PIPE_FORMAT_B10G10R10A2_UNORM
:
161 return VDP_RGBA_FORMAT_B10G10R10A2
;
162 case PIPE_FORMAT_B8G8R8A8_UNORM
:
163 return VDP_RGBA_FORMAT_B8G8R8A8
;
164 case PIPE_FORMAT_R10G10B10A2_UNORM
:
165 return VDP_RGBA_FORMAT_R10G10B10A2
;
166 case PIPE_FORMAT_R8G8B8A8_UNORM
:
167 return VDP_RGBA_FORMAT_R8G8B8A8
;
175 static inline enum pipe_format
176 FormatIndexedToPipe(VdpRGBAFormat vdpau_format
)
178 switch (vdpau_format
) {
179 case VDP_INDEXED_FORMAT_A4I4
:
180 return PIPE_FORMAT_A4R4_UNORM
;
181 case VDP_INDEXED_FORMAT_I4A4
:
182 return PIPE_FORMAT_R4A4_UNORM
;
183 case VDP_INDEXED_FORMAT_A8I8
:
184 return PIPE_FORMAT_A8R8_UNORM
;
185 case VDP_INDEXED_FORMAT_I8A8
:
186 return PIPE_FORMAT_R8A8_UNORM
;
191 return PIPE_FORMAT_NONE
;
194 static inline enum pipe_format
195 FormatColorTableToPipe(VdpColorTableFormat vdpau_format
)
197 switch(vdpau_format
) {
198 case VDP_COLOR_TABLE_FORMAT_B8G8R8X8
:
199 return PIPE_FORMAT_B8G8R8X8_UNORM
;
204 return PIPE_FORMAT_NONE
;
207 static inline enum pipe_video_profile
208 ProfileToPipe(VdpDecoderProfile vdpau_profile
)
210 switch (vdpau_profile
) {
211 case VDP_DECODER_PROFILE_MPEG1
:
212 return PIPE_VIDEO_PROFILE_MPEG1
;
213 case VDP_DECODER_PROFILE_MPEG2_SIMPLE
:
214 return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE
;
215 case VDP_DECODER_PROFILE_MPEG2_MAIN
:
216 return PIPE_VIDEO_PROFILE_MPEG2_MAIN
;
217 case VDP_DECODER_PROFILE_H264_BASELINE
:
218 return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE
;
219 case VDP_DECODER_PROFILE_H264_MAIN
:
220 return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN
;
221 case VDP_DECODER_PROFILE_H264_HIGH
:
222 return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH
;
224 return PIPE_VIDEO_PROFILE_UNKNOWN
;
228 static inline VdpDecoderProfile
229 PipeToProfile(enum pipe_video_profile p_profile
)
232 case PIPE_VIDEO_PROFILE_MPEG1
:
233 return VDP_DECODER_PROFILE_MPEG1
;
234 case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE
:
235 return VDP_DECODER_PROFILE_MPEG2_SIMPLE
;
236 case PIPE_VIDEO_PROFILE_MPEG2_MAIN
:
237 return VDP_DECODER_PROFILE_MPEG2_MAIN
;
238 case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE
:
239 return VDP_DECODER_PROFILE_H264_BASELINE
;
240 case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN
:
241 return VDP_DECODER_PROFILE_H264_MAIN
;
242 case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH
:
243 return VDP_DECODER_PROFILE_H264_HIGH
;
250 static inline struct pipe_video_rect
*
251 RectToPipe(const VdpRect
*src
, struct pipe_video_rect
*dst
)
254 dst
->x
= MIN2(src
->x1
, src
->x0
);
255 dst
->y
= MIN2(src
->y1
, src
->y0
);
256 dst
->w
= abs(src
->x1
- src
->x0
);
257 dst
->h
= abs(src
->y1
- src
->y0
);
265 struct vl_screen
*vscreen
;
266 struct vl_context
*context
;
267 struct vl_compositor compositor
;
274 } vlVdpPresentationQueueTarget
;
280 struct vl_compositor compositor
;
281 } vlVdpPresentationQueue
;
286 struct vl_compositor compositor
;
292 struct pipe_video_buffer
*video_buffer
;
295 typedef uint64_t vlVdpTime
;
301 struct pipe_surface
*surface
;
302 struct pipe_sampler_view
*sampler_view
;
303 struct pipe_fence_handle
*fence
;
304 } vlVdpOutputSurface
;
309 struct pipe_video_decoder
*decoder
;
310 unsigned num_buffers
;
315 typedef uint32_t vlHandle
;
317 boolean
vlCreateHTAB(void);
318 void vlDestroyHTAB(void);
319 vlHandle
vlAddDataHTAB(void *data
);
320 void* vlGetDataHTAB(vlHandle handle
);
321 void vlRemoveDataHTAB(vlHandle handle
);
323 boolean
vlGetFuncFTAB(VdpFuncId function_id
, void **func
);
325 /* Public functions */
326 VdpDeviceCreateX11 vdp_imp_device_create_x11
;
327 VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11
;
329 /* Internal function pointers */
330 VdpGetErrorString vlVdpGetErrorString
;
331 VdpDeviceDestroy vlVdpDeviceDestroy
;
332 VdpGetProcAddress vlVdpGetProcAddress
;
333 VdpGetApiVersion vlVdpGetApiVersion
;
334 VdpGetInformationString vlVdpGetInformationString
;
335 VdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities
;
336 VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities
;
337 VdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities
;
338 VdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities
;
339 VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities
;
340 VdpOutputSurfaceQueryPutBitsIndexedCapabilities vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities
;
341 VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities
;
342 VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities
;
343 VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport
;
344 VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport
;
345 VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange
;
346 VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport
;
347 VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange
;
348 VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate
;
349 VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy
;
350 VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters
;
351 VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr
;
352 VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr
;
353 VdpDecoderCreate vlVdpDecoderCreate
;
354 VdpDecoderDestroy vlVdpDecoderDestroy
;
355 VdpDecoderGetParameters vlVdpDecoderGetParameters
;
356 VdpDecoderRender vlVdpDecoderRender
;
357 VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate
;
358 VdpOutputSurfaceDestroy vlVdpOutputSurfaceDestroy
;
359 VdpOutputSurfaceGetParameters vlVdpOutputSurfaceGetParameters
;
360 VdpOutputSurfaceGetBitsNative vlVdpOutputSurfaceGetBitsNative
;
361 VdpOutputSurfacePutBitsNative vlVdpOutputSurfacePutBitsNative
;
362 VdpOutputSurfacePutBitsIndexed vlVdpOutputSurfacePutBitsIndexed
;
363 VdpOutputSurfacePutBitsYCbCr vlVdpOutputSurfacePutBitsYCbCr
;
364 VdpOutputSurfaceRenderOutputSurface vlVdpOutputSurfaceRenderOutputSurface
;
365 VdpOutputSurfaceRenderBitmapSurface vlVdpOutputSurfaceRenderBitmapSurface
;
366 VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate
;
367 VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy
;
368 VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters
;
369 VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative
;
370 VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy
;
371 VdpPresentationQueueCreate vlVdpPresentationQueueCreate
;
372 VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy
;
373 VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor
;
374 VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor
;
375 VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime
;
376 VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay
;
377 VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle
;
378 VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus
;
379 VdpPreemptionCallback vlVdpPreemptionCallback
;
380 VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister
;
381 VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables
;
382 VdpVideoMixerCreate vlVdpVideoMixerCreate
;
383 VdpVideoMixerRender vlVdpVideoMixerRender
;
384 VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues
;
385 VdpVideoMixerGetFeatureSupport vlVdpVideoMixerGetFeatureSupport
;
386 VdpVideoMixerGetFeatureEnables vlVdpVideoMixerGetFeatureEnables
;
387 VdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues
;
388 VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues
;
389 VdpVideoMixerDestroy vlVdpVideoMixerDestroy
;
390 VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix
;
395 #define VDPAU_TRACE 3
397 static inline void VDPAU_MSG(unsigned int level
, const char *fmt
, ...)
399 static int debug_level
= -1;
401 if (debug_level
== -1) {
402 debug_level
= MAX2(debug_get_num_option("VDPAU_DEBUG", 0), 0);
405 if (level
<= debug_level
) {
408 _debug_vprintf(fmt
, ap
);
413 #endif /* VDPAU_PRIVATE_H */