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 "util/u_rect.h"
41 #include "vl/vl_compositor.h"
43 #include "vl_winsys.h"
45 /* Full VDPAU API documentation available at :
46 * ftp://download.nvidia.com/XFree86/vdpau/doxygen/html/index.html */
48 #define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR
50 #define TOSTRING(x) QUOTEME(x)
51 #define INFORMATION_STRING TOSTRING(INFORMATION)
54 static inline enum pipe_video_chroma_format
55 ChromaToPipe(VdpChromaType vdpau_type
)
58 case VDP_CHROMA_TYPE_420
:
59 return PIPE_VIDEO_CHROMA_FORMAT_420
;
60 case VDP_CHROMA_TYPE_422
:
61 return PIPE_VIDEO_CHROMA_FORMAT_422
;
62 case VDP_CHROMA_TYPE_444
:
63 return PIPE_VIDEO_CHROMA_FORMAT_444
;
71 static inline VdpChromaType
72 PipeToChroma(enum pipe_video_chroma_format pipe_type
)
75 case PIPE_VIDEO_CHROMA_FORMAT_420
:
76 return VDP_CHROMA_TYPE_420
;
77 case PIPE_VIDEO_CHROMA_FORMAT_422
:
78 return VDP_CHROMA_TYPE_422
;
79 case PIPE_VIDEO_CHROMA_FORMAT_444
:
80 return VDP_CHROMA_TYPE_444
;
88 static inline enum pipe_format
89 FormatYCBCRToPipe(VdpYCbCrFormat vdpau_format
)
91 switch (vdpau_format
) {
92 case VDP_YCBCR_FORMAT_NV12
:
93 return PIPE_FORMAT_NV12
;
94 case VDP_YCBCR_FORMAT_YV12
:
95 return PIPE_FORMAT_YV12
;
96 case VDP_YCBCR_FORMAT_UYVY
:
97 return PIPE_FORMAT_UYVY
;
98 case VDP_YCBCR_FORMAT_YUYV
:
99 return PIPE_FORMAT_YUYV
;
100 case VDP_YCBCR_FORMAT_Y8U8V8A8
: /* Not defined in p_format.h */
101 return PIPE_FORMAT_NONE
;
102 case VDP_YCBCR_FORMAT_V8U8Y8A8
:
103 return PIPE_FORMAT_VUYA
;
108 return PIPE_FORMAT_NONE
;
111 static inline VdpYCbCrFormat
112 PipeToFormatYCBCR(enum pipe_format p_format
)
115 case PIPE_FORMAT_NV12
:
116 return VDP_YCBCR_FORMAT_NV12
;
117 case PIPE_FORMAT_YV12
:
118 return VDP_YCBCR_FORMAT_YV12
;
119 case PIPE_FORMAT_UYVY
:
120 return VDP_YCBCR_FORMAT_UYVY
;
121 case PIPE_FORMAT_YUYV
:
122 return VDP_YCBCR_FORMAT_YUYV
;
123 //case PIPE_FORMAT_YUVA:
124 // return VDP_YCBCR_FORMAT_Y8U8V8A8;
125 case PIPE_FORMAT_VUYA
:
126 return VDP_YCBCR_FORMAT_V8U8Y8A8
;
134 static inline enum pipe_format
135 FormatRGBAToPipe(VdpRGBAFormat vdpau_format
)
137 switch (vdpau_format
) {
138 case VDP_RGBA_FORMAT_A8
:
139 return PIPE_FORMAT_A8_UNORM
;
140 case VDP_RGBA_FORMAT_B10G10R10A2
:
141 return PIPE_FORMAT_B10G10R10A2_UNORM
;
142 case VDP_RGBA_FORMAT_B8G8R8A8
:
143 return PIPE_FORMAT_B8G8R8A8_UNORM
;
144 case VDP_RGBA_FORMAT_R10G10B10A2
:
145 return PIPE_FORMAT_R10G10B10A2_UNORM
;
146 case VDP_RGBA_FORMAT_R8G8B8A8
:
147 return PIPE_FORMAT_R8G8B8A8_UNORM
;
152 return PIPE_FORMAT_NONE
;
155 static inline VdpRGBAFormat
156 PipeToFormatRGBA(enum pipe_format p_format
)
159 case PIPE_FORMAT_A8_UNORM
:
160 return VDP_RGBA_FORMAT_A8
;
161 case PIPE_FORMAT_B10G10R10A2_UNORM
:
162 return VDP_RGBA_FORMAT_B10G10R10A2
;
163 case PIPE_FORMAT_B8G8R8A8_UNORM
:
164 return VDP_RGBA_FORMAT_B8G8R8A8
;
165 case PIPE_FORMAT_R10G10B10A2_UNORM
:
166 return VDP_RGBA_FORMAT_R10G10B10A2
;
167 case PIPE_FORMAT_R8G8B8A8_UNORM
:
168 return VDP_RGBA_FORMAT_R8G8B8A8
;
176 static inline enum pipe_format
177 FormatIndexedToPipe(VdpRGBAFormat vdpau_format
)
179 switch (vdpau_format
) {
180 case VDP_INDEXED_FORMAT_A4I4
:
181 return PIPE_FORMAT_A4R4_UNORM
;
182 case VDP_INDEXED_FORMAT_I4A4
:
183 return PIPE_FORMAT_R4A4_UNORM
;
184 case VDP_INDEXED_FORMAT_A8I8
:
185 return PIPE_FORMAT_A8R8_UNORM
;
186 case VDP_INDEXED_FORMAT_I8A8
:
187 return PIPE_FORMAT_R8A8_UNORM
;
192 return PIPE_FORMAT_NONE
;
195 static inline enum pipe_format
196 FormatColorTableToPipe(VdpColorTableFormat vdpau_format
)
198 switch(vdpau_format
) {
199 case VDP_COLOR_TABLE_FORMAT_B8G8R8X8
:
200 return PIPE_FORMAT_B8G8R8X8_UNORM
;
205 return PIPE_FORMAT_NONE
;
208 static inline enum pipe_video_profile
209 ProfileToPipe(VdpDecoderProfile vdpau_profile
)
211 switch (vdpau_profile
) {
212 case VDP_DECODER_PROFILE_MPEG1
:
213 return PIPE_VIDEO_PROFILE_MPEG1
;
214 case VDP_DECODER_PROFILE_MPEG2_SIMPLE
:
215 return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE
;
216 case VDP_DECODER_PROFILE_MPEG2_MAIN
:
217 return PIPE_VIDEO_PROFILE_MPEG2_MAIN
;
218 case VDP_DECODER_PROFILE_H264_BASELINE
:
219 return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE
;
220 case VDP_DECODER_PROFILE_H264_MAIN
:
221 return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN
;
222 case VDP_DECODER_PROFILE_H264_HIGH
:
223 return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH
;
224 case VDP_DECODER_PROFILE_MPEG4_PART2_SP
:
225 return PIPE_VIDEO_PROFILE_MPEG4_SIMPLE
;
226 case VDP_DECODER_PROFILE_MPEG4_PART2_ASP
:
227 return PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE
;
228 case VDP_DECODER_PROFILE_VC1_SIMPLE
:
229 return PIPE_VIDEO_PROFILE_VC1_SIMPLE
;
230 case VDP_DECODER_PROFILE_VC1_MAIN
:
231 return PIPE_VIDEO_PROFILE_VC1_MAIN
;
232 case VDP_DECODER_PROFILE_VC1_ADVANCED
:
233 return PIPE_VIDEO_PROFILE_VC1_ADVANCED
;
235 return PIPE_VIDEO_PROFILE_UNKNOWN
;
239 static inline VdpDecoderProfile
240 PipeToProfile(enum pipe_video_profile p_profile
)
243 case PIPE_VIDEO_PROFILE_MPEG1
:
244 return VDP_DECODER_PROFILE_MPEG1
;
245 case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE
:
246 return VDP_DECODER_PROFILE_MPEG2_SIMPLE
;
247 case PIPE_VIDEO_PROFILE_MPEG2_MAIN
:
248 return VDP_DECODER_PROFILE_MPEG2_MAIN
;
249 case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE
:
250 return VDP_DECODER_PROFILE_H264_BASELINE
;
251 case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN
:
252 return VDP_DECODER_PROFILE_H264_MAIN
;
253 case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH
:
254 return VDP_DECODER_PROFILE_H264_HIGH
;
255 case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE
:
256 return VDP_DECODER_PROFILE_MPEG4_PART2_SP
;
257 case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE
:
258 return VDP_DECODER_PROFILE_MPEG4_PART2_ASP
;
259 case PIPE_VIDEO_PROFILE_VC1_SIMPLE
:
260 return VDP_DECODER_PROFILE_VC1_SIMPLE
;
261 case PIPE_VIDEO_PROFILE_VC1_MAIN
:
262 return VDP_DECODER_PROFILE_VC1_MAIN
;
263 case PIPE_VIDEO_PROFILE_VC1_ADVANCED
:
264 return VDP_DECODER_PROFILE_VC1_ADVANCED
;
271 static inline struct pipe_video_rect
*
272 RectToPipe(const VdpRect
*src
, struct pipe_video_rect
*dst
)
275 dst
->x
= MIN2(src
->x1
, src
->x0
);
276 dst
->y
= MIN2(src
->y1
, src
->y0
);
277 dst
->w
= abs(src
->x1
- src
->x0
);
278 dst
->h
= abs(src
->y1
- src
->y0
);
286 struct vl_screen
*vscreen
;
287 struct vl_context
*context
;
288 struct vl_compositor compositor
;
295 } vlVdpPresentationQueueTarget
;
301 struct vl_compositor compositor
;
302 struct u_rect dirty_area
;
303 } vlVdpPresentationQueue
;
308 struct vl_compositor compositor
;
309 unsigned video_width
, video_height
;
310 enum pipe_video_chroma_format chroma_format
;
311 unsigned max_layers
, skip_chroma_deint
, custom_csc
;
312 float luma_key_min
, luma_key_max
, sharpness
, noise_reduction_level
;
319 struct pipe_video_buffer templat
, *video_buffer
;
322 typedef uint64_t vlVdpTime
;
328 struct pipe_surface
*surface
;
329 struct pipe_sampler_view
*sampler_view
;
330 struct pipe_fence_handle
*fence
;
331 struct u_rect dirty_area
;
332 } vlVdpOutputSurface
;
337 struct pipe_video_decoder
*decoder
;
340 typedef uint32_t vlHandle
;
342 boolean
vlCreateHTAB(void);
343 void vlDestroyHTAB(void);
344 vlHandle
vlAddDataHTAB(void *data
);
345 void* vlGetDataHTAB(vlHandle handle
);
346 void vlRemoveDataHTAB(vlHandle handle
);
348 boolean
vlGetFuncFTAB(VdpFuncId function_id
, void **func
);
350 /* Public functions */
351 VdpDeviceCreateX11 vdp_imp_device_create_x11
;
352 VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11
;
354 /* Internal function pointers */
355 VdpGetErrorString vlVdpGetErrorString
;
356 VdpDeviceDestroy vlVdpDeviceDestroy
;
357 VdpGetProcAddress vlVdpGetProcAddress
;
358 VdpGetApiVersion vlVdpGetApiVersion
;
359 VdpGetInformationString vlVdpGetInformationString
;
360 VdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities
;
361 VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities
;
362 VdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities
;
363 VdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities
;
364 VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities
;
365 VdpOutputSurfaceQueryPutBitsIndexedCapabilities vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities
;
366 VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities
;
367 VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities
;
368 VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport
;
369 VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport
;
370 VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange
;
371 VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport
;
372 VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange
;
373 VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate
;
374 VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy
;
375 VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters
;
376 VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr
;
377 VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr
;
378 VdpDecoderCreate vlVdpDecoderCreate
;
379 VdpDecoderDestroy vlVdpDecoderDestroy
;
380 VdpDecoderGetParameters vlVdpDecoderGetParameters
;
381 VdpDecoderRender vlVdpDecoderRender
;
382 VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate
;
383 VdpOutputSurfaceDestroy vlVdpOutputSurfaceDestroy
;
384 VdpOutputSurfaceGetParameters vlVdpOutputSurfaceGetParameters
;
385 VdpOutputSurfaceGetBitsNative vlVdpOutputSurfaceGetBitsNative
;
386 VdpOutputSurfacePutBitsNative vlVdpOutputSurfacePutBitsNative
;
387 VdpOutputSurfacePutBitsIndexed vlVdpOutputSurfacePutBitsIndexed
;
388 VdpOutputSurfacePutBitsYCbCr vlVdpOutputSurfacePutBitsYCbCr
;
389 VdpOutputSurfaceRenderOutputSurface vlVdpOutputSurfaceRenderOutputSurface
;
390 VdpOutputSurfaceRenderBitmapSurface vlVdpOutputSurfaceRenderBitmapSurface
;
391 VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate
;
392 VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy
;
393 VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters
;
394 VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative
;
395 VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy
;
396 VdpPresentationQueueCreate vlVdpPresentationQueueCreate
;
397 VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy
;
398 VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor
;
399 VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor
;
400 VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime
;
401 VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay
;
402 VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle
;
403 VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus
;
404 VdpPreemptionCallback vlVdpPreemptionCallback
;
405 VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister
;
406 VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables
;
407 VdpVideoMixerCreate vlVdpVideoMixerCreate
;
408 VdpVideoMixerRender vlVdpVideoMixerRender
;
409 VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues
;
410 VdpVideoMixerGetFeatureSupport vlVdpVideoMixerGetFeatureSupport
;
411 VdpVideoMixerGetFeatureEnables vlVdpVideoMixerGetFeatureEnables
;
412 VdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues
;
413 VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues
;
414 VdpVideoMixerDestroy vlVdpVideoMixerDestroy
;
415 VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix
;
420 #define VDPAU_TRACE 3
422 static inline void VDPAU_MSG(unsigned int level
, const char *fmt
, ...)
424 static int debug_level
= -1;
426 if (debug_level
== -1) {
427 debug_level
= MAX2(debug_get_num_option("VDPAU_DEBUG", 0), 0);
430 if (level
<= debug_level
) {
433 _debug_vprintf(fmt
, ap
);
438 #endif /* VDPAU_PRIVATE_H */