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_context.h>
39 #include <util/u_debug.h>
41 #include <vl_winsys.h>
43 #define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR
45 #define TOSTRING(x) QUOTEME(x)
46 #define INFORMATION_STRING TOSTRING(INFORMATION)
48 #define VL_NUM_DECODE_BUFFERS 4
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 FormatToPipe(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 */
99 case VDP_YCBCR_FORMAT_V8U8Y8A8
:
100 return PIPE_FORMAT_VUYA
;
108 static inline enum pipe_format
109 FormatRGBAToPipe(VdpRGBAFormat vdpau_format
)
111 switch (vdpau_format
) {
112 case VDP_RGBA_FORMAT_A8
:
113 return PIPE_FORMAT_A8_UNORM
;
114 case VDP_RGBA_FORMAT_B10G10R10A2
:
115 return PIPE_FORMAT_B10G10R10A2_UNORM
;
116 case VDP_RGBA_FORMAT_B8G8R8A8
:
117 return PIPE_FORMAT_B8G8R8A8_UNORM
;
118 case VDP_RGBA_FORMAT_R10G10B10A2
:
119 return PIPE_FORMAT_R10G10B10A2_UNORM
;
120 case VDP_RGBA_FORMAT_R8G8B8A8
:
121 return PIPE_FORMAT_R8G8B8A8_UNORM
;
129 static inline VdpYCbCrFormat
130 PipeToFormat(enum pipe_format p_format
)
133 case PIPE_FORMAT_NV12
:
134 return VDP_YCBCR_FORMAT_NV12
;
135 case PIPE_FORMAT_YV12
:
136 return VDP_YCBCR_FORMAT_YV12
;
137 case PIPE_FORMAT_UYVY
:
138 return VDP_YCBCR_FORMAT_UYVY
;
139 case PIPE_FORMAT_YUYV
:
140 return VDP_YCBCR_FORMAT_YUYV
;
141 //case PIPE_FORMAT_YUVA:
142 // return VDP_YCBCR_FORMAT_Y8U8V8A8;
143 case PIPE_FORMAT_VUYA
:
144 return VDP_YCBCR_FORMAT_V8U8Y8A8
;
152 static inline enum pipe_video_profile
153 ProfileToPipe(VdpDecoderProfile vdpau_profile
)
155 switch (vdpau_profile
) {
156 case VDP_DECODER_PROFILE_MPEG1
:
157 return PIPE_VIDEO_PROFILE_MPEG1
;
158 case VDP_DECODER_PROFILE_MPEG2_SIMPLE
:
159 return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE
;
160 case VDP_DECODER_PROFILE_MPEG2_MAIN
:
161 return PIPE_VIDEO_PROFILE_MPEG2_MAIN
;
162 case VDP_DECODER_PROFILE_H264_BASELINE
:
163 return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE
;
164 case VDP_DECODER_PROFILE_H264_MAIN
: /* Not defined in p_format.h */
165 return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN
;
166 case VDP_DECODER_PROFILE_H264_HIGH
:
167 return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH
;
169 return PIPE_VIDEO_PROFILE_UNKNOWN
;
177 struct vl_screen
*vscreen
;
178 struct vl_context
*context
;
185 } vlVdpPresentationQueueTarget
;
191 struct pipe_video_compositor
*compositor
;
192 } vlVdpPresentationQueue
;
197 struct pipe_video_compositor
*compositor
;
203 struct pipe_video_buffer
*video_buffer
;
209 struct pipe_surface
*surface
;
210 struct pipe_sampler_view
*sampler_view
;
211 } vlVdpOutputSurface
;
216 struct pipe_video_decoder
*decoder
;
217 struct pipe_video_decode_buffer
*buffer
[VL_NUM_DECODE_BUFFERS
];
221 typedef uint32_t vlHandle
;
223 boolean
vlCreateHTAB(void);
224 void vlDestroyHTAB(void);
225 vlHandle
vlAddDataHTAB(void *data
);
226 void* vlGetDataHTAB(vlHandle handle
);
227 void vlRemoveDataHTAB(vlHandle handle
);
229 boolean
vlGetFuncFTAB(VdpFuncId function_id
, void **func
);
231 /* Public functions */
232 VdpDeviceCreateX11 vdp_imp_device_create_x11
;
233 VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11
;
235 /* Internal function pointers */
236 VdpGetErrorString vlVdpGetErrorString
;
237 VdpDeviceDestroy vlVdpDeviceDestroy
;
238 VdpGetProcAddress vlVdpGetProcAddress
;
239 VdpGetApiVersion vlVdpGetApiVersion
;
240 VdpGetInformationString vlVdpGetInformationString
;
241 VdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities
;
242 VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities
;
243 VdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities
;
244 VdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities
;
245 VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities
;
246 VdpOutputSurfaceQueryPutBitsIndexedCapabilities vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities
;
247 VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities
;
248 VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities
;
249 VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport
;
250 VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport
;
251 VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange
;
252 VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport
;
253 VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange
;
254 VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate
;
255 VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy
;
256 VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters
;
257 VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr
;
258 VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr
;
259 VdpDecoderCreate vlVdpDecoderCreate
;
260 VdpDecoderDestroy vlVdpDecoderDestroy
;
261 VdpDecoderGetParameters vlVdpDecoderGetParameters
;
262 VdpDecoderRender vlVdpDecoderRender
;
263 VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate
;
264 VdpOutputSurfaceDestroy vlVdpOutputSurfaceDestroy
;
265 VdpOutputSurfaceGetParameters vlVdpOutputSurfaceGetParameters
;
266 VdpOutputSurfaceGetBitsNative vlVdpOutputSurfaceGetBitsNative
;
267 VdpOutputSurfacePutBitsNative vlVdpOutputSurfacePutBitsNative
;
268 VdpOutputSurfacePutBitsIndexed vlVdpOutputSurfacePutBitsIndexed
;
269 VdpOutputSurfacePutBitsYCbCr vlVdpOutputSurfacePutBitsYCbCr
;
270 VdpOutputSurfaceRenderOutputSurface vlVdpOutputSurfaceRenderOutputSurface
;
271 VdpOutputSurfaceRenderBitmapSurface vlVdpOutputSurfaceRenderBitmapSurface
;
272 VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate
;
273 VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy
;
274 VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters
;
275 VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative
;
276 VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy
;
277 VdpPresentationQueueCreate vlVdpPresentationQueueCreate
;
278 VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy
;
279 VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor
;
280 VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor
;
281 VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime
;
282 VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay
;
283 VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle
;
284 VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus
;
285 VdpPreemptionCallback vlVdpPreemptionCallback
;
286 VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister
;
287 VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables
;
288 VdpVideoMixerCreate vlVdpVideoMixerCreate
;
289 VdpVideoMixerRender vlVdpVideoMixerRender
;
290 VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues
;
291 VdpVideoMixerGetFeatureSupport vlVdpVideoMixerGetFeatureSupport
;
292 VdpVideoMixerGetFeatureEnables vlVdpVideoMixerGetFeatureEnables
;
293 VdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues
;
294 VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues
;
295 VdpVideoMixerDestroy vlVdpVideoMixerDestroy
;
296 VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix
;
301 #define VDPAU_TRACE 3
303 static inline void VDPAU_MSG(unsigned int level
, const char *fmt
, ...)
305 static int debug_level
= -1;
307 if (debug_level
== -1) {
308 debug_level
= MAX2(debug_get_num_option("VDPAU_DEBUG", 0), 0);
311 if (level
<= debug_level
) {
314 _debug_vprintf(fmt
, ap
);
319 #endif // VDPAU_PRIVATE_H