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)
49 #define VL_NUM_DECODE_BUFFERS 4
51 static inline enum pipe_video_chroma_format
52 ChromaToPipe(VdpChromaType vdpau_type
)
55 case VDP_CHROMA_TYPE_420
:
56 return PIPE_VIDEO_CHROMA_FORMAT_420
;
57 case VDP_CHROMA_TYPE_422
:
58 return PIPE_VIDEO_CHROMA_FORMAT_422
;
59 case VDP_CHROMA_TYPE_444
:
60 return PIPE_VIDEO_CHROMA_FORMAT_444
;
68 static inline VdpChromaType
69 PipeToChroma(enum pipe_video_chroma_format pipe_type
)
72 case PIPE_VIDEO_CHROMA_FORMAT_420
:
73 return VDP_CHROMA_TYPE_420
;
74 case PIPE_VIDEO_CHROMA_FORMAT_422
:
75 return VDP_CHROMA_TYPE_422
;
76 case PIPE_VIDEO_CHROMA_FORMAT_444
:
77 return VDP_CHROMA_TYPE_444
;
86 static inline enum pipe_format
87 FormatToPipe(VdpYCbCrFormat vdpau_format
)
89 switch (vdpau_format
) {
90 case VDP_YCBCR_FORMAT_NV12
:
91 return PIPE_FORMAT_NV12
;
92 case VDP_YCBCR_FORMAT_YV12
:
93 return PIPE_FORMAT_YV12
;
94 case VDP_YCBCR_FORMAT_UYVY
:
95 return PIPE_FORMAT_UYVY
;
96 case VDP_YCBCR_FORMAT_YUYV
:
97 return PIPE_FORMAT_YUYV
;
98 case VDP_YCBCR_FORMAT_Y8U8V8A8
: /* Not defined in p_format.h */
100 case VDP_YCBCR_FORMAT_V8U8Y8A8
:
101 return PIPE_FORMAT_VUYA
;
109 static inline enum pipe_format
110 FormatRGBAToPipe(VdpRGBAFormat vdpau_format
)
112 switch (vdpau_format
) {
113 case VDP_RGBA_FORMAT_A8
:
114 return PIPE_FORMAT_A8_UNORM
;
115 case VDP_RGBA_FORMAT_B10G10R10A2
:
116 return PIPE_FORMAT_B10G10R10A2_UNORM
;
117 case VDP_RGBA_FORMAT_B8G8R8A8
:
118 return PIPE_FORMAT_B8G8R8A8_UNORM
;
119 case VDP_RGBA_FORMAT_R10G10B10A2
:
120 return PIPE_FORMAT_R10G10B10A2_UNORM
;
121 case VDP_RGBA_FORMAT_R8G8B8A8
:
122 return PIPE_FORMAT_R8G8B8A8_UNORM
;
130 static inline VdpYCbCrFormat
131 PipeToFormat(enum pipe_format p_format
)
134 case PIPE_FORMAT_NV12
:
135 return VDP_YCBCR_FORMAT_NV12
;
136 case PIPE_FORMAT_YV12
:
137 return VDP_YCBCR_FORMAT_YV12
;
138 case PIPE_FORMAT_UYVY
:
139 return VDP_YCBCR_FORMAT_UYVY
;
140 case PIPE_FORMAT_YUYV
:
141 return VDP_YCBCR_FORMAT_YUYV
;
142 //case PIPE_FORMAT_YUVA:
143 // return VDP_YCBCR_FORMAT_Y8U8V8A8;
144 case PIPE_FORMAT_VUYA
:
145 return VDP_YCBCR_FORMAT_V8U8Y8A8
;
153 static inline enum pipe_video_profile
154 ProfileToPipe(VdpDecoderProfile vdpau_profile
)
156 switch (vdpau_profile
) {
157 case VDP_DECODER_PROFILE_MPEG1
:
158 return PIPE_VIDEO_PROFILE_MPEG1
;
159 case VDP_DECODER_PROFILE_MPEG2_SIMPLE
:
160 return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE
;
161 case VDP_DECODER_PROFILE_MPEG2_MAIN
:
162 return PIPE_VIDEO_PROFILE_MPEG2_MAIN
;
163 case VDP_DECODER_PROFILE_H264_BASELINE
:
164 return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE
;
165 case VDP_DECODER_PROFILE_H264_MAIN
: /* Not defined in p_format.h */
166 return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN
;
167 case VDP_DECODER_PROFILE_H264_HIGH
:
168 return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH
;
170 return PIPE_VIDEO_PROFILE_UNKNOWN
;
178 struct vl_screen
*vscreen
;
179 struct vl_context
*context
;
186 } vlVdpPresentationQueueTarget
;
192 struct vl_compositor compositor
;
193 } vlVdpPresentationQueue
;
198 struct vl_compositor compositor
;
204 struct pipe_video_buffer
*video_buffer
;
210 struct pipe_surface
*surface
;
211 struct pipe_sampler_view
*sampler_view
;
212 } vlVdpOutputSurface
;
217 struct pipe_video_decoder
*decoder
;
218 struct pipe_video_decode_buffer
*buffer
[VL_NUM_DECODE_BUFFERS
];
222 typedef uint32_t vlHandle
;
224 boolean
vlCreateHTAB(void);
225 void vlDestroyHTAB(void);
226 vlHandle
vlAddDataHTAB(void *data
);
227 void* vlGetDataHTAB(vlHandle handle
);
228 void vlRemoveDataHTAB(vlHandle handle
);
230 boolean
vlGetFuncFTAB(VdpFuncId function_id
, void **func
);
232 /* Public functions */
233 VdpDeviceCreateX11 vdp_imp_device_create_x11
;
234 VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11
;
236 /* Internal function pointers */
237 VdpGetErrorString vlVdpGetErrorString
;
238 VdpDeviceDestroy vlVdpDeviceDestroy
;
239 VdpGetProcAddress vlVdpGetProcAddress
;
240 VdpGetApiVersion vlVdpGetApiVersion
;
241 VdpGetInformationString vlVdpGetInformationString
;
242 VdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities
;
243 VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities
;
244 VdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities
;
245 VdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities
;
246 VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities
;
247 VdpOutputSurfaceQueryPutBitsIndexedCapabilities vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities
;
248 VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities
;
249 VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities
;
250 VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport
;
251 VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport
;
252 VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange
;
253 VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport
;
254 VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange
;
255 VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate
;
256 VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy
;
257 VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters
;
258 VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr
;
259 VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr
;
260 VdpDecoderCreate vlVdpDecoderCreate
;
261 VdpDecoderDestroy vlVdpDecoderDestroy
;
262 VdpDecoderGetParameters vlVdpDecoderGetParameters
;
263 VdpDecoderRender vlVdpDecoderRender
;
264 VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate
;
265 VdpOutputSurfaceDestroy vlVdpOutputSurfaceDestroy
;
266 VdpOutputSurfaceGetParameters vlVdpOutputSurfaceGetParameters
;
267 VdpOutputSurfaceGetBitsNative vlVdpOutputSurfaceGetBitsNative
;
268 VdpOutputSurfacePutBitsNative vlVdpOutputSurfacePutBitsNative
;
269 VdpOutputSurfacePutBitsIndexed vlVdpOutputSurfacePutBitsIndexed
;
270 VdpOutputSurfacePutBitsYCbCr vlVdpOutputSurfacePutBitsYCbCr
;
271 VdpOutputSurfaceRenderOutputSurface vlVdpOutputSurfaceRenderOutputSurface
;
272 VdpOutputSurfaceRenderBitmapSurface vlVdpOutputSurfaceRenderBitmapSurface
;
273 VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate
;
274 VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy
;
275 VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters
;
276 VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative
;
277 VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy
;
278 VdpPresentationQueueCreate vlVdpPresentationQueueCreate
;
279 VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy
;
280 VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor
;
281 VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor
;
282 VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime
;
283 VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay
;
284 VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle
;
285 VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus
;
286 VdpPreemptionCallback vlVdpPreemptionCallback
;
287 VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister
;
288 VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables
;
289 VdpVideoMixerCreate vlVdpVideoMixerCreate
;
290 VdpVideoMixerRender vlVdpVideoMixerRender
;
291 VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues
;
292 VdpVideoMixerGetFeatureSupport vlVdpVideoMixerGetFeatureSupport
;
293 VdpVideoMixerGetFeatureEnables vlVdpVideoMixerGetFeatureEnables
;
294 VdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues
;
295 VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues
;
296 VdpVideoMixerDestroy vlVdpVideoMixerDestroy
;
297 VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix
;
302 #define VDPAU_TRACE 3
304 static inline void VDPAU_MSG(unsigned int level
, const char *fmt
, ...)
306 static int debug_level
= -1;
308 if (debug_level
== -1) {
309 debug_level
= MAX2(debug_get_num_option("VDPAU_DEBUG", 0), 0);
312 if (level
<= debug_level
) {
315 _debug_vprintf(fmt
, ap
);
320 #endif // VDPAU_PRIVATE_H