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"
42 #include "vl/vl_matrix_filter.h"
43 #include "vl/vl_median_filter.h"
45 #include "vl_winsys.h"
47 /* Full VDPAU API documentation available at :
48 * ftp://download.nvidia.com/XFree86/vdpau/doxygen/html/index.html */
50 #define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR
52 #define TOSTRING(x) QUOTEME(x)
53 #define INFORMATION_STRING TOSTRING(INFORMATION)
56 static inline enum pipe_video_chroma_format
57 ChromaToPipe(VdpChromaType vdpau_type
)
60 case VDP_CHROMA_TYPE_420
:
61 return PIPE_VIDEO_CHROMA_FORMAT_420
;
62 case VDP_CHROMA_TYPE_422
:
63 return PIPE_VIDEO_CHROMA_FORMAT_422
;
64 case VDP_CHROMA_TYPE_444
:
65 return PIPE_VIDEO_CHROMA_FORMAT_444
;
73 static inline VdpChromaType
74 PipeToChroma(enum pipe_video_chroma_format pipe_type
)
77 case PIPE_VIDEO_CHROMA_FORMAT_420
:
78 return VDP_CHROMA_TYPE_420
;
79 case PIPE_VIDEO_CHROMA_FORMAT_422
:
80 return VDP_CHROMA_TYPE_422
;
81 case PIPE_VIDEO_CHROMA_FORMAT_444
:
82 return VDP_CHROMA_TYPE_444
;
90 static inline enum pipe_format
91 FormatYCBCRToPipe(VdpYCbCrFormat vdpau_format
)
93 switch (vdpau_format
) {
94 case VDP_YCBCR_FORMAT_NV12
:
95 return PIPE_FORMAT_NV12
;
96 case VDP_YCBCR_FORMAT_YV12
:
97 return PIPE_FORMAT_YV12
;
98 case VDP_YCBCR_FORMAT_UYVY
:
99 return PIPE_FORMAT_UYVY
;
100 case VDP_YCBCR_FORMAT_YUYV
:
101 return PIPE_FORMAT_YUYV
;
102 case VDP_YCBCR_FORMAT_Y8U8V8A8
: /* Not defined in p_format.h */
103 return PIPE_FORMAT_NONE
;
104 case VDP_YCBCR_FORMAT_V8U8Y8A8
:
105 return PIPE_FORMAT_VUYA
;
110 return PIPE_FORMAT_NONE
;
113 static inline VdpYCbCrFormat
114 PipeToFormatYCBCR(enum pipe_format p_format
)
117 case PIPE_FORMAT_NV12
:
118 return VDP_YCBCR_FORMAT_NV12
;
119 case PIPE_FORMAT_YV12
:
120 return VDP_YCBCR_FORMAT_YV12
;
121 case PIPE_FORMAT_UYVY
:
122 return VDP_YCBCR_FORMAT_UYVY
;
123 case PIPE_FORMAT_YUYV
:
124 return VDP_YCBCR_FORMAT_YUYV
;
125 //case PIPE_FORMAT_YUVA:
126 // return VDP_YCBCR_FORMAT_Y8U8V8A8;
127 case PIPE_FORMAT_VUYA
:
128 return VDP_YCBCR_FORMAT_V8U8Y8A8
;
136 static inline enum pipe_format
137 FormatRGBAToPipe(VdpRGBAFormat vdpau_format
)
139 switch (vdpau_format
) {
140 case VDP_RGBA_FORMAT_A8
:
141 return PIPE_FORMAT_A8_UNORM
;
142 case VDP_RGBA_FORMAT_B10G10R10A2
:
143 return PIPE_FORMAT_B10G10R10A2_UNORM
;
144 case VDP_RGBA_FORMAT_B8G8R8A8
:
145 return PIPE_FORMAT_B8G8R8A8_UNORM
;
146 case VDP_RGBA_FORMAT_R10G10B10A2
:
147 return PIPE_FORMAT_R10G10B10A2_UNORM
;
148 case VDP_RGBA_FORMAT_R8G8B8A8
:
149 return PIPE_FORMAT_R8G8B8A8_UNORM
;
154 return PIPE_FORMAT_NONE
;
157 static inline VdpRGBAFormat
158 PipeToFormatRGBA(enum pipe_format p_format
)
161 case PIPE_FORMAT_A8_UNORM
:
162 return VDP_RGBA_FORMAT_A8
;
163 case PIPE_FORMAT_B10G10R10A2_UNORM
:
164 return VDP_RGBA_FORMAT_B10G10R10A2
;
165 case PIPE_FORMAT_B8G8R8A8_UNORM
:
166 return VDP_RGBA_FORMAT_B8G8R8A8
;
167 case PIPE_FORMAT_R10G10B10A2_UNORM
:
168 return VDP_RGBA_FORMAT_R10G10B10A2
;
169 case PIPE_FORMAT_R8G8B8A8_UNORM
:
170 return VDP_RGBA_FORMAT_R8G8B8A8
;
178 static inline enum pipe_format
179 FormatIndexedToPipe(VdpRGBAFormat vdpau_format
)
181 switch (vdpau_format
) {
182 case VDP_INDEXED_FORMAT_A4I4
:
183 return PIPE_FORMAT_A4R4_UNORM
;
184 case VDP_INDEXED_FORMAT_I4A4
:
185 return PIPE_FORMAT_R4A4_UNORM
;
186 case VDP_INDEXED_FORMAT_A8I8
:
187 return PIPE_FORMAT_A8R8_UNORM
;
188 case VDP_INDEXED_FORMAT_I8A8
:
189 return PIPE_FORMAT_R8A8_UNORM
;
194 return PIPE_FORMAT_NONE
;
197 static inline enum pipe_format
198 FormatColorTableToPipe(VdpColorTableFormat vdpau_format
)
200 switch(vdpau_format
) {
201 case VDP_COLOR_TABLE_FORMAT_B8G8R8X8
:
202 return PIPE_FORMAT_B8G8R8X8_UNORM
;
207 return PIPE_FORMAT_NONE
;
210 static inline enum pipe_video_profile
211 ProfileToPipe(VdpDecoderProfile vdpau_profile
)
213 switch (vdpau_profile
) {
214 case VDP_DECODER_PROFILE_MPEG1
:
215 return PIPE_VIDEO_PROFILE_MPEG1
;
216 case VDP_DECODER_PROFILE_MPEG2_SIMPLE
:
217 return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE
;
218 case VDP_DECODER_PROFILE_MPEG2_MAIN
:
219 return PIPE_VIDEO_PROFILE_MPEG2_MAIN
;
220 case VDP_DECODER_PROFILE_H264_BASELINE
:
221 return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE
;
222 case VDP_DECODER_PROFILE_H264_MAIN
:
223 return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN
;
224 case VDP_DECODER_PROFILE_H264_HIGH
:
225 return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH
;
226 case VDP_DECODER_PROFILE_MPEG4_PART2_SP
:
227 return PIPE_VIDEO_PROFILE_MPEG4_SIMPLE
;
228 case VDP_DECODER_PROFILE_MPEG4_PART2_ASP
:
229 return PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE
;
230 case VDP_DECODER_PROFILE_VC1_SIMPLE
:
231 return PIPE_VIDEO_PROFILE_VC1_SIMPLE
;
232 case VDP_DECODER_PROFILE_VC1_MAIN
:
233 return PIPE_VIDEO_PROFILE_VC1_MAIN
;
234 case VDP_DECODER_PROFILE_VC1_ADVANCED
:
235 return PIPE_VIDEO_PROFILE_VC1_ADVANCED
;
237 return PIPE_VIDEO_PROFILE_UNKNOWN
;
241 static inline VdpDecoderProfile
242 PipeToProfile(enum pipe_video_profile p_profile
)
245 case PIPE_VIDEO_PROFILE_MPEG1
:
246 return VDP_DECODER_PROFILE_MPEG1
;
247 case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE
:
248 return VDP_DECODER_PROFILE_MPEG2_SIMPLE
;
249 case PIPE_VIDEO_PROFILE_MPEG2_MAIN
:
250 return VDP_DECODER_PROFILE_MPEG2_MAIN
;
251 case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE
:
252 return VDP_DECODER_PROFILE_H264_BASELINE
;
253 case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN
:
254 return VDP_DECODER_PROFILE_H264_MAIN
;
255 case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH
:
256 return VDP_DECODER_PROFILE_H264_HIGH
;
257 case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE
:
258 return VDP_DECODER_PROFILE_MPEG4_PART2_SP
;
259 case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE
:
260 return VDP_DECODER_PROFILE_MPEG4_PART2_ASP
;
261 case PIPE_VIDEO_PROFILE_VC1_SIMPLE
:
262 return VDP_DECODER_PROFILE_VC1_SIMPLE
;
263 case PIPE_VIDEO_PROFILE_VC1_MAIN
:
264 return VDP_DECODER_PROFILE_VC1_MAIN
;
265 case PIPE_VIDEO_PROFILE_VC1_ADVANCED
:
266 return VDP_DECODER_PROFILE_VC1_ADVANCED
;
273 static inline struct pipe_video_rect
*
274 RectToPipe(const VdpRect
*src
, struct pipe_video_rect
*dst
)
277 dst
->x
= MIN2(src
->x1
, src
->x0
);
278 dst
->y
= MIN2(src
->y1
, src
->y0
);
279 dst
->w
= abs(src
->x1
- src
->x0
);
280 dst
->h
= abs(src
->y1
- src
->y0
);
288 struct vl_screen
*vscreen
;
289 struct pipe_context
*context
;
290 struct vl_compositor compositor
;
297 } vlVdpPresentationQueueTarget
;
303 struct vl_compositor compositor
;
304 } vlVdpPresentationQueue
;
309 struct vl_compositor compositor
;
312 bool supported
, enabled
;
314 struct vl_median_filter
*filter
;
318 bool supported
, enabled
;
320 struct vl_matrix_filter
*filter
;
323 unsigned video_width
, video_height
;
324 enum pipe_video_chroma_format chroma_format
;
325 unsigned max_layers
, skip_chroma_deint
, custom_csc
;
326 float luma_key_min
, luma_key_max
;
333 struct pipe_video_buffer templat
, *video_buffer
;
336 typedef uint64_t vlVdpTime
;
342 struct pipe_surface
*surface
;
343 struct pipe_sampler_view
*sampler_view
;
344 struct pipe_fence_handle
*fence
;
345 struct u_rect dirty_area
;
346 } vlVdpOutputSurface
;
351 struct pipe_video_decoder
*decoder
;
354 typedef uint32_t vlHandle
;
356 boolean
vlCreateHTAB(void);
357 void vlDestroyHTAB(void);
358 vlHandle
vlAddDataHTAB(void *data
);
359 void* vlGetDataHTAB(vlHandle handle
);
360 void vlRemoveDataHTAB(vlHandle handle
);
362 boolean
vlGetFuncFTAB(VdpFuncId function_id
, void **func
);
364 /* Public functions */
365 VdpDeviceCreateX11 vdp_imp_device_create_x11
;
366 VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11
;
368 /* Internal function pointers */
369 VdpGetErrorString vlVdpGetErrorString
;
370 VdpDeviceDestroy vlVdpDeviceDestroy
;
371 VdpGetProcAddress vlVdpGetProcAddress
;
372 VdpGetApiVersion vlVdpGetApiVersion
;
373 VdpGetInformationString vlVdpGetInformationString
;
374 VdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities
;
375 VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities
;
376 VdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities
;
377 VdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities
;
378 VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities
;
379 VdpOutputSurfaceQueryPutBitsIndexedCapabilities vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities
;
380 VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities
;
381 VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities
;
382 VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport
;
383 VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport
;
384 VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange
;
385 VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport
;
386 VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange
;
387 VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate
;
388 VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy
;
389 VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters
;
390 VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr
;
391 VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr
;
392 VdpDecoderCreate vlVdpDecoderCreate
;
393 VdpDecoderDestroy vlVdpDecoderDestroy
;
394 VdpDecoderGetParameters vlVdpDecoderGetParameters
;
395 VdpDecoderRender vlVdpDecoderRender
;
396 VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate
;
397 VdpOutputSurfaceDestroy vlVdpOutputSurfaceDestroy
;
398 VdpOutputSurfaceGetParameters vlVdpOutputSurfaceGetParameters
;
399 VdpOutputSurfaceGetBitsNative vlVdpOutputSurfaceGetBitsNative
;
400 VdpOutputSurfacePutBitsNative vlVdpOutputSurfacePutBitsNative
;
401 VdpOutputSurfacePutBitsIndexed vlVdpOutputSurfacePutBitsIndexed
;
402 VdpOutputSurfacePutBitsYCbCr vlVdpOutputSurfacePutBitsYCbCr
;
403 VdpOutputSurfaceRenderOutputSurface vlVdpOutputSurfaceRenderOutputSurface
;
404 VdpOutputSurfaceRenderBitmapSurface vlVdpOutputSurfaceRenderBitmapSurface
;
405 VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate
;
406 VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy
;
407 VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters
;
408 VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative
;
409 VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy
;
410 VdpPresentationQueueCreate vlVdpPresentationQueueCreate
;
411 VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy
;
412 VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor
;
413 VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor
;
414 VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime
;
415 VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay
;
416 VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle
;
417 VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus
;
418 VdpPreemptionCallback vlVdpPreemptionCallback
;
419 VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister
;
420 VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables
;
421 VdpVideoMixerCreate vlVdpVideoMixerCreate
;
422 VdpVideoMixerRender vlVdpVideoMixerRender
;
423 VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues
;
424 VdpVideoMixerGetFeatureSupport vlVdpVideoMixerGetFeatureSupport
;
425 VdpVideoMixerGetFeatureEnables vlVdpVideoMixerGetFeatureEnables
;
426 VdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues
;
427 VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues
;
428 VdpVideoMixerDestroy vlVdpVideoMixerDestroy
;
429 VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix
;
434 #define VDPAU_TRACE 3
436 static inline void VDPAU_MSG(unsigned int level
, const char *fmt
, ...)
438 static int debug_level
= -1;
440 if (debug_level
== -1) {
441 debug_level
= MAX2(debug_get_num_option("VDPAU_DEBUG", 0), 0);
444 if (level
<= debug_level
) {
447 _debug_vprintf(fmt
, ap
);
452 #endif /* VDPAU_PRIVATE_H */