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 #define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR
46 #define TOSTRING(x) QUOTEME(x)
47 #define INFORMATION_STRING TOSTRING(INFORMATION)
50 static inline enum pipe_video_chroma_format
51 ChromaToPipe(VdpChromaType 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
;
67 static inline VdpChromaType
68 PipeToChroma(enum pipe_video_chroma_format 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
;
85 static inline enum pipe_format
86 FormatYCBCRToPipe(VdpYCbCrFormat vdpau_format
)
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 PIPE_FORMAT_NONE
;
99 case VDP_YCBCR_FORMAT_V8U8Y8A8
:
100 return PIPE_FORMAT_VUYA
;
105 return PIPE_FORMAT_NONE
;
108 static inline VdpYCbCrFormat
109 PipeToFormatYCBCR(enum pipe_format 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
;
131 static inline enum pipe_format
132 FormatRGBAToPipe(VdpRGBAFormat vdpau_format
)
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
;
149 return PIPE_FORMAT_NONE
;
152 static inline VdpRGBAFormat
153 PipeToFormatRGBA(enum pipe_format 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
;
173 static inline enum pipe_format
174 FormatIndexedToPipe(VdpRGBAFormat vdpau_format
)
176 switch (vdpau_format
) {
177 case VDP_INDEXED_FORMAT_A4I4
:
178 return PIPE_FORMAT_A4R4_UNORM
;
179 case VDP_INDEXED_FORMAT_I4A4
:
180 return PIPE_FORMAT_R4A4_UNORM
;
181 case VDP_INDEXED_FORMAT_A8I8
:
182 return PIPE_FORMAT_A8R8_UNORM
;
183 case VDP_INDEXED_FORMAT_I8A8
:
184 return PIPE_FORMAT_R8A8_UNORM
;
189 return PIPE_FORMAT_NONE
;
192 static inline enum pipe_format
193 FormatColorTableToPipe(VdpColorTableFormat vdpau_format
)
195 switch(vdpau_format
) {
196 case VDP_COLOR_TABLE_FORMAT_B8G8R8X8
:
197 return PIPE_FORMAT_B8G8R8X8_UNORM
;
201 return PIPE_FORMAT_NONE
;
205 static inline enum pipe_video_profile
206 ProfileToPipe(VdpDecoderProfile vdpau_profile
)
208 switch (vdpau_profile
) {
209 case VDP_DECODER_PROFILE_MPEG1
:
210 return PIPE_VIDEO_PROFILE_MPEG1
;
211 case VDP_DECODER_PROFILE_MPEG2_SIMPLE
:
212 return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE
;
213 case VDP_DECODER_PROFILE_MPEG2_MAIN
:
214 return PIPE_VIDEO_PROFILE_MPEG2_MAIN
;
215 case VDP_DECODER_PROFILE_H264_BASELINE
:
216 return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE
;
217 case VDP_DECODER_PROFILE_H264_MAIN
: /* Not defined in p_format.h */
218 return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN
;
219 case VDP_DECODER_PROFILE_H264_HIGH
:
220 return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH
;
222 return PIPE_VIDEO_PROFILE_UNKNOWN
;
226 static inline VdpDecoderProfile
227 PipeToProfile(enum pipe_video_profile p_profile
)
230 case PIPE_VIDEO_PROFILE_MPEG1
:
231 return VDP_DECODER_PROFILE_MPEG1
;
232 case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE
:
233 return VDP_DECODER_PROFILE_MPEG2_SIMPLE
;
234 case PIPE_VIDEO_PROFILE_MPEG2_MAIN
:
235 return VDP_DECODER_PROFILE_MPEG2_MAIN
;
236 case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE
:
237 return VDP_DECODER_PROFILE_H264_BASELINE
;
238 case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN
: /* Not defined in p_format.h */
239 return VDP_DECODER_PROFILE_H264_MAIN
;
240 case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH
:
241 return VDP_DECODER_PROFILE_H264_HIGH
;
248 static inline struct pipe_video_rect
*
249 RectToPipe(const VdpRect
*src
, struct pipe_video_rect
*dst
)
252 dst
->x
= MIN2(src
->x1
, src
->x0
);
253 dst
->y
= MIN2(src
->y1
, src
->y0
);
254 dst
->w
= abs(src
->x1
- src
->x0
);
255 dst
->h
= abs(src
->y1
- src
->y0
);
263 struct vl_screen
*vscreen
;
264 struct vl_context
*context
;
265 struct vl_compositor compositor
;
272 } vlVdpPresentationQueueTarget
;
278 struct vl_compositor compositor
;
279 } vlVdpPresentationQueue
;
284 struct vl_compositor compositor
;
290 struct pipe_video_buffer
*video_buffer
;
296 struct pipe_surface
*surface
;
297 struct pipe_sampler_view
*sampler_view
;
298 } vlVdpOutputSurface
;
303 struct pipe_video_decoder
*decoder
;
304 unsigned num_buffers
;
309 typedef uint32_t vlHandle
;
311 boolean
vlCreateHTAB(void);
312 void vlDestroyHTAB(void);
313 vlHandle
vlAddDataHTAB(void *data
);
314 void* vlGetDataHTAB(vlHandle handle
);
315 void vlRemoveDataHTAB(vlHandle handle
);
317 boolean
vlGetFuncFTAB(VdpFuncId function_id
, void **func
);
319 /* Public functions */
320 VdpDeviceCreateX11 vdp_imp_device_create_x11
;
321 VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11
;
323 /* Internal function pointers */
324 VdpGetErrorString vlVdpGetErrorString
;
325 VdpDeviceDestroy vlVdpDeviceDestroy
;
326 VdpGetProcAddress vlVdpGetProcAddress
;
327 VdpGetApiVersion vlVdpGetApiVersion
;
328 VdpGetInformationString vlVdpGetInformationString
;
329 VdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities
;
330 VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities
;
331 VdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities
;
332 VdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities
;
333 VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities
;
334 VdpOutputSurfaceQueryPutBitsIndexedCapabilities vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities
;
335 VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities
;
336 VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities
;
337 VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport
;
338 VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport
;
339 VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange
;
340 VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport
;
341 VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange
;
342 VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate
;
343 VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy
;
344 VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters
;
345 VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr
;
346 VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr
;
347 VdpDecoderCreate vlVdpDecoderCreate
;
348 VdpDecoderDestroy vlVdpDecoderDestroy
;
349 VdpDecoderGetParameters vlVdpDecoderGetParameters
;
350 VdpDecoderRender vlVdpDecoderRender
;
351 VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate
;
352 VdpOutputSurfaceDestroy vlVdpOutputSurfaceDestroy
;
353 VdpOutputSurfaceGetParameters vlVdpOutputSurfaceGetParameters
;
354 VdpOutputSurfaceGetBitsNative vlVdpOutputSurfaceGetBitsNative
;
355 VdpOutputSurfacePutBitsNative vlVdpOutputSurfacePutBitsNative
;
356 VdpOutputSurfacePutBitsIndexed vlVdpOutputSurfacePutBitsIndexed
;
357 VdpOutputSurfacePutBitsYCbCr vlVdpOutputSurfacePutBitsYCbCr
;
358 VdpOutputSurfaceRenderOutputSurface vlVdpOutputSurfaceRenderOutputSurface
;
359 VdpOutputSurfaceRenderBitmapSurface vlVdpOutputSurfaceRenderBitmapSurface
;
360 VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate
;
361 VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy
;
362 VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters
;
363 VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative
;
364 VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy
;
365 VdpPresentationQueueCreate vlVdpPresentationQueueCreate
;
366 VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy
;
367 VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor
;
368 VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor
;
369 VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime
;
370 VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay
;
371 VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle
;
372 VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus
;
373 VdpPreemptionCallback vlVdpPreemptionCallback
;
374 VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister
;
375 VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables
;
376 VdpVideoMixerCreate vlVdpVideoMixerCreate
;
377 VdpVideoMixerRender vlVdpVideoMixerRender
;
378 VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues
;
379 VdpVideoMixerGetFeatureSupport vlVdpVideoMixerGetFeatureSupport
;
380 VdpVideoMixerGetFeatureEnables vlVdpVideoMixerGetFeatureEnables
;
381 VdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues
;
382 VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues
;
383 VdpVideoMixerDestroy vlVdpVideoMixerDestroy
;
384 VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix
;
389 #define VDPAU_TRACE 3
391 static inline void VDPAU_MSG(unsigned int level
, const char *fmt
, ...)
393 static int debug_level
= -1;
395 if (debug_level
== -1) {
396 debug_level
= MAX2(debug_get_num_option("VDPAU_DEBUG", 0), 0);
399 if (level
<= debug_level
) {
402 _debug_vprintf(fmt
, ap
);
407 #endif // VDPAU_PRIVATE_H