1 /**************************************************************************
2  *
3  * Copyright 2010 Younes Manton & Thomas Balling Sørensen.
4  * All Rights Reserved.
5  *
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:
13  *
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the Software.
17  *
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 VMWARE 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.
25  *
26  **************************************************************************/
27 
28 #ifndef VDPAU_PRIVATE_H
29 #define VDPAU_PRIVATE_H
30 
31 #include <assert.h>
32 
33 #include <vdpau/vdpau.h>
34 #include <vdpau/vdpau_x11.h>
35 
36 #include "pipe/p_compiler.h"
37 #include "pipe/p_video_codec.h"
38 
39 #include "frontend/vdpau_interop.h"
40 #include "frontend/vdpau_dmabuf.h"
41 #include "frontend/vdpau_funcs.h"
42 
43 #include "util/u_debug.h"
44 #include "util/u_rect.h"
45 #include "os/os_thread.h"
46 
47 #include "vl/vl_video_buffer.h"
48 #include "vl/vl_bicubic_filter.h"
49 #include "vl/vl_compositor.h"
50 #include "vl/vl_csc.h"
51 #include "vl/vl_deint_filter.h"
52 #include "vl/vl_matrix_filter.h"
53 #include "vl/vl_median_filter.h"
54 #include "vl/vl_winsys.h"
55 
56 /* Full VDPAU API documentation available at :
57  * ftp://download.nvidia.com/XFree86/vdpau/doxygen/html/index.html */
58 
59 #define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR
60 #define QUOTEME(x) #x
61 #define TOSTRING(x) QUOTEME(x)
62 #define INFORMATION_STRING TOSTRING(INFORMATION)
63 
64 static inline enum pipe_video_chroma_format
ChromaToPipe(VdpChromaType vdpau_type)65 ChromaToPipe(VdpChromaType vdpau_type)
66 {
67    switch (vdpau_type) {
68       case VDP_CHROMA_TYPE_420:
69          return PIPE_VIDEO_CHROMA_FORMAT_420;
70       case VDP_CHROMA_TYPE_422:
71          return PIPE_VIDEO_CHROMA_FORMAT_422;
72       case VDP_CHROMA_TYPE_444:
73          return PIPE_VIDEO_CHROMA_FORMAT_444;
74       default:
75          assert(0);
76    }
77 
78    return -1;
79 }
80 
81 static inline VdpChromaType
PipeToChroma(enum pipe_video_chroma_format pipe_type)82 PipeToChroma(enum pipe_video_chroma_format pipe_type)
83 {
84    switch (pipe_type) {
85       case PIPE_VIDEO_CHROMA_FORMAT_420:
86          return VDP_CHROMA_TYPE_420;
87       case PIPE_VIDEO_CHROMA_FORMAT_422:
88          return VDP_CHROMA_TYPE_422;
89       case PIPE_VIDEO_CHROMA_FORMAT_444:
90          return VDP_CHROMA_TYPE_444;
91       default:
92          assert(0);
93    }
94 
95    return -1;
96 }
97 
98 static inline enum pipe_video_chroma_format
FormatYCBCRToPipeChroma(VdpYCbCrFormat vdpau_format)99 FormatYCBCRToPipeChroma(VdpYCbCrFormat vdpau_format)
100 {
101    switch (vdpau_format) {
102       case VDP_YCBCR_FORMAT_NV12:
103          return PIPE_VIDEO_CHROMA_FORMAT_420;
104       case VDP_YCBCR_FORMAT_YV12:
105          return PIPE_VIDEO_CHROMA_FORMAT_420;
106       case VDP_YCBCR_FORMAT_UYVY:
107          return PIPE_VIDEO_CHROMA_FORMAT_422;
108       case VDP_YCBCR_FORMAT_YUYV:
109          return PIPE_VIDEO_CHROMA_FORMAT_422;
110       case VDP_YCBCR_FORMAT_Y8U8V8A8:
111          return PIPE_VIDEO_CHROMA_FORMAT_444;
112       case VDP_YCBCR_FORMAT_V8U8Y8A8:
113          return PIPE_VIDEO_CHROMA_FORMAT_444;
114       default:
115          assert(0);
116    }
117 
118    return PIPE_VIDEO_CHROMA_FORMAT_NONE;
119 }
120 
121 static inline enum pipe_format
FormatYCBCRToPipe(VdpYCbCrFormat vdpau_format)122 FormatYCBCRToPipe(VdpYCbCrFormat vdpau_format)
123 {
124    switch (vdpau_format) {
125       case VDP_YCBCR_FORMAT_NV12:
126          return PIPE_FORMAT_NV12;
127       case VDP_YCBCR_FORMAT_YV12:
128          return PIPE_FORMAT_YV12;
129       case VDP_YCBCR_FORMAT_UYVY:
130          return PIPE_FORMAT_UYVY;
131       case VDP_YCBCR_FORMAT_YUYV:
132          return PIPE_FORMAT_YUYV;
133       case VDP_YCBCR_FORMAT_Y8U8V8A8:
134          return PIPE_FORMAT_R8G8B8A8_UNORM;
135       case VDP_YCBCR_FORMAT_V8U8Y8A8:
136          return PIPE_FORMAT_B8G8R8A8_UNORM;
137 #ifdef VDP_YCBCR_FORMAT_P010
138       case VDP_YCBCR_FORMAT_P010:
139          return PIPE_FORMAT_P010;
140 #endif
141 #ifdef VDP_YCBCR_FORMAT_P016
142       case VDP_YCBCR_FORMAT_P016:
143          return PIPE_FORMAT_P016;
144 #endif
145       default:
146          /* NOTE: Can't be "unreachable", as it's quite reachable. */
147          debug_assert(!"unexpected VdpYCbCrFormat");
148 #if defined(NDEBUG) || defined(DEBUG)
149          FALLTHROUGH;
150 #endif
151 #ifdef VDP_YCBCR_FORMAT_Y_UV_444
152       case VDP_YCBCR_FORMAT_Y_UV_444:
153 #endif
154 #ifdef VDP_YCBCR_FORMAT_Y_U_V_444
155       case VDP_YCBCR_FORMAT_Y_U_V_444:
156 #endif
157 #ifdef VDP_YCBCR_FORMAT_Y_U_V_444_16
158       case VDP_YCBCR_FORMAT_Y_U_V_444_16:
159 #endif
160          return PIPE_FORMAT_NONE;
161    }
162 
163 }
164 
165 static inline VdpYCbCrFormat
PipeToFormatYCBCR(enum pipe_format p_format)166 PipeToFormatYCBCR(enum pipe_format p_format)
167 {
168    switch (p_format) {
169       case PIPE_FORMAT_NV12:
170          return VDP_YCBCR_FORMAT_NV12;
171       case PIPE_FORMAT_YV12:
172          return VDP_YCBCR_FORMAT_YV12;
173       case PIPE_FORMAT_UYVY:
174          return VDP_YCBCR_FORMAT_UYVY;
175       case PIPE_FORMAT_YUYV:
176          return VDP_YCBCR_FORMAT_YUYV;
177       case PIPE_FORMAT_R8G8B8A8_UNORM:
178         return VDP_YCBCR_FORMAT_Y8U8V8A8;
179       case PIPE_FORMAT_B8G8R8A8_UNORM:
180          return VDP_YCBCR_FORMAT_V8U8Y8A8;
181       default:
182          assert(0);
183    }
184 
185    return -1;
186 }
187 
188 static inline VdpRGBAFormat
PipeToFormatRGBA(enum pipe_format p_format)189 PipeToFormatRGBA(enum pipe_format p_format)
190 {
191    switch (p_format) {
192       case PIPE_FORMAT_A8_UNORM:
193          return VDP_RGBA_FORMAT_A8;
194       case PIPE_FORMAT_B10G10R10A2_UNORM:
195          return VDP_RGBA_FORMAT_B10G10R10A2;
196       case PIPE_FORMAT_B8G8R8A8_UNORM:
197          return VDP_RGBA_FORMAT_B8G8R8A8;
198       case PIPE_FORMAT_R10G10B10A2_UNORM:
199          return VDP_RGBA_FORMAT_R10G10B10A2;
200       case PIPE_FORMAT_R8G8B8A8_UNORM:
201          return VDP_RGBA_FORMAT_R8G8B8A8;
202       default:
203          assert(0);
204    }
205 
206    return -1;
207 }
208 
209 static inline enum pipe_format
FormatIndexedToPipe(VdpRGBAFormat vdpau_format)210 FormatIndexedToPipe(VdpRGBAFormat vdpau_format)
211 {
212    switch (vdpau_format) {
213       case VDP_INDEXED_FORMAT_A4I4:
214          return PIPE_FORMAT_R4A4_UNORM;
215       case VDP_INDEXED_FORMAT_I4A4:
216          return PIPE_FORMAT_A4R4_UNORM;
217       case VDP_INDEXED_FORMAT_A8I8:
218          return PIPE_FORMAT_A8R8_UNORM;
219       case VDP_INDEXED_FORMAT_I8A8:
220          return PIPE_FORMAT_R8A8_UNORM;
221       default:
222          assert(0);
223    }
224 
225    return PIPE_FORMAT_NONE;
226 }
227 
228 static inline enum pipe_format
FormatColorTableToPipe(VdpColorTableFormat vdpau_format)229 FormatColorTableToPipe(VdpColorTableFormat vdpau_format)
230 {
231    switch(vdpau_format) {
232       case VDP_COLOR_TABLE_FORMAT_B8G8R8X8:
233          return PIPE_FORMAT_B8G8R8X8_UNORM;
234       default:
235          assert(0);
236    }
237 
238    return PIPE_FORMAT_NONE;
239 }
240 
241 static inline enum pipe_video_profile
ProfileToPipe(VdpDecoderProfile vdpau_profile)242 ProfileToPipe(VdpDecoderProfile vdpau_profile)
243 {
244    switch (vdpau_profile) {
245       case VDP_DECODER_PROFILE_MPEG1:
246          return PIPE_VIDEO_PROFILE_MPEG1;
247       case VDP_DECODER_PROFILE_MPEG2_SIMPLE:
248          return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE;
249       case VDP_DECODER_PROFILE_MPEG2_MAIN:
250          return PIPE_VIDEO_PROFILE_MPEG2_MAIN;
251       case VDP_DECODER_PROFILE_H264_BASELINE:
252          return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE;
253       case VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE:
254          return PIPE_VIDEO_PROFILE_MPEG4_AVC_CONSTRAINED_BASELINE;
255       case VDP_DECODER_PROFILE_H264_MAIN:
256          return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN;
257       case VDP_DECODER_PROFILE_H264_HIGH:
258          return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
259       case VDP_DECODER_PROFILE_MPEG4_PART2_SP:
260          return PIPE_VIDEO_PROFILE_MPEG4_SIMPLE;
261       case VDP_DECODER_PROFILE_MPEG4_PART2_ASP:
262          return PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE;
263       case VDP_DECODER_PROFILE_VC1_SIMPLE:
264          return PIPE_VIDEO_PROFILE_VC1_SIMPLE;
265       case VDP_DECODER_PROFILE_VC1_MAIN:
266          return PIPE_VIDEO_PROFILE_VC1_MAIN;
267       case VDP_DECODER_PROFILE_VC1_ADVANCED:
268          return PIPE_VIDEO_PROFILE_VC1_ADVANCED;
269       case VDP_DECODER_PROFILE_HEVC_MAIN:
270          return PIPE_VIDEO_PROFILE_HEVC_MAIN;
271       case VDP_DECODER_PROFILE_HEVC_MAIN_10:
272          return PIPE_VIDEO_PROFILE_HEVC_MAIN_10;
273       case VDP_DECODER_PROFILE_HEVC_MAIN_STILL:
274          return PIPE_VIDEO_PROFILE_HEVC_MAIN_STILL;
275       case VDP_DECODER_PROFILE_HEVC_MAIN_12:
276          return PIPE_VIDEO_PROFILE_HEVC_MAIN_12;
277       case VDP_DECODER_PROFILE_HEVC_MAIN_444:
278          return PIPE_VIDEO_PROFILE_HEVC_MAIN_444;
279       default:
280          return PIPE_VIDEO_PROFILE_UNKNOWN;
281    }
282 }
283 
284 static inline VdpDecoderProfile
PipeToProfile(enum pipe_video_profile p_profile)285 PipeToProfile(enum pipe_video_profile p_profile)
286 {
287    switch (p_profile) {
288       case PIPE_VIDEO_PROFILE_MPEG1:
289          return VDP_DECODER_PROFILE_MPEG1;
290       case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:
291          return VDP_DECODER_PROFILE_MPEG2_SIMPLE;
292       case PIPE_VIDEO_PROFILE_MPEG2_MAIN:
293          return VDP_DECODER_PROFILE_MPEG2_MAIN;
294       case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE:
295          return VDP_DECODER_PROFILE_H264_BASELINE;
296       case PIPE_VIDEO_PROFILE_MPEG4_AVC_CONSTRAINED_BASELINE:
297          return VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE;
298       case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN:
299          return VDP_DECODER_PROFILE_H264_MAIN;
300       case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH:
301          return VDP_DECODER_PROFILE_H264_HIGH;
302       case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE:
303          return VDP_DECODER_PROFILE_MPEG4_PART2_SP;
304       case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE:
305          return VDP_DECODER_PROFILE_MPEG4_PART2_ASP;
306       case PIPE_VIDEO_PROFILE_VC1_SIMPLE:
307          return VDP_DECODER_PROFILE_VC1_SIMPLE;
308       case PIPE_VIDEO_PROFILE_VC1_MAIN:
309          return VDP_DECODER_PROFILE_VC1_MAIN;
310       case PIPE_VIDEO_PROFILE_VC1_ADVANCED:
311          return VDP_DECODER_PROFILE_VC1_ADVANCED;
312       case PIPE_VIDEO_PROFILE_HEVC_MAIN:
313          return VDP_DECODER_PROFILE_HEVC_MAIN;
314       case PIPE_VIDEO_PROFILE_HEVC_MAIN_10:
315          return VDP_DECODER_PROFILE_HEVC_MAIN_10;
316       case PIPE_VIDEO_PROFILE_HEVC_MAIN_STILL:
317          return VDP_DECODER_PROFILE_HEVC_MAIN_STILL;
318       case PIPE_VIDEO_PROFILE_HEVC_MAIN_12:
319          return VDP_DECODER_PROFILE_HEVC_MAIN_12;
320       case PIPE_VIDEO_PROFILE_HEVC_MAIN_444:
321          return VDP_DECODER_PROFILE_HEVC_MAIN_444;
322       default:
323          assert(0);
324          return -1;
325    }
326 }
327 
328 static inline struct u_rect *
RectToPipe(const VdpRect * src,struct u_rect * dst)329 RectToPipe(const VdpRect *src, struct u_rect *dst)
330 {
331    if (src) {
332       dst->x0 = src->x0;
333       dst->y0 = src->y0;
334       dst->x1 = src->x1;
335       dst->y1 = src->y1;
336       return dst;
337    }
338    return NULL;
339 }
340 
341 static inline struct pipe_box
RectToPipeBox(const VdpRect * rect,struct pipe_resource * res)342 RectToPipeBox(const VdpRect *rect, struct pipe_resource *res)
343 {
344    struct pipe_box box;
345 
346    box.x = 0;
347    box.y = 0;
348    box.z = 0;
349    box.width = res->width0;
350    box.height = res->height0;
351    box.depth = 1;
352 
353    if (rect) {
354       if (rect->x1 > rect->x0 &&
355           rect->y1 > rect->y0) {
356          box.x = rect->x0;
357          box.y = rect->y0;
358          box.width = rect->x1 - box.x;
359          box.height = rect->y1 - box.y;
360       } else {
361          box.width = 0;
362          box.height = 0;
363       }
364    }
365 
366    return box;
367 }
368 
369 static inline bool
CheckSurfaceParams(struct pipe_screen * screen,const struct pipe_resource * templ)370 CheckSurfaceParams(struct pipe_screen *screen,
371                    const struct pipe_resource *templ)
372 {
373    return screen->is_format_supported(screen, templ->format, templ->target,
374                                       templ->nr_samples,
375                                       templ->nr_storage_samples, templ->bind);
376 }
377 
378 typedef struct
379 {
380    struct pipe_reference reference;
381    struct vl_screen *vscreen;
382    struct pipe_context *context;
383    struct vl_compositor compositor;
384    struct pipe_sampler_view *dummy_sv;
385    mtx_t mutex;
386 } vlVdpDevice;
387 
388 typedef struct
389 {
390    vlVdpDevice *device;
391    struct vl_compositor_state cstate;
392 
393    struct {
394        bool supported, enabled;
395        float luma_min, luma_max;
396    } luma_key;
397 
398    struct {
399 	  bool supported, enabled, spatial;
400 	  struct vl_deint_filter *filter;
401    } deint;
402 
403    struct {
404 	  bool supported, enabled;
405 	  struct vl_bicubic_filter *filter;
406    } bicubic;
407 
408    struct {
409       bool supported, enabled;
410       unsigned level;
411       struct vl_median_filter *filter;
412    } noise_reduction;
413 
414    struct {
415       bool supported, enabled;
416       float value;
417       struct vl_matrix_filter *filter;
418    } sharpness;
419 
420    unsigned video_width, video_height;
421    enum pipe_video_chroma_format chroma_format;
422    unsigned max_layers, skip_chroma_deint;
423 
424    bool custom_csc;
425    vl_csc_matrix csc;
426 } vlVdpVideoMixer;
427 
428 typedef struct
429 {
430    vlVdpDevice *device;
431    struct pipe_video_buffer templat, *video_buffer;
432 } vlVdpSurface;
433 
434 typedef struct
435 {
436    vlVdpDevice *device;
437    struct pipe_sampler_view *sampler_view;
438 } vlVdpBitmapSurface;
439 
440 typedef uint64_t vlVdpTime;
441 
442 typedef struct
443 {
444    vlVdpDevice *device;
445    struct pipe_surface *surface;
446    struct pipe_sampler_view *sampler_view;
447    struct pipe_fence_handle *fence;
448    struct vl_compositor_state cstate;
449    struct u_rect dirty_area;
450    bool send_to_X;
451 } vlVdpOutputSurface;
452 
453 typedef struct
454 {
455    vlVdpDevice *device;
456    Drawable drawable;
457 } vlVdpPresentationQueueTarget;
458 
459 typedef struct
460 {
461    vlVdpDevice *device;
462    Drawable drawable;
463    struct vl_compositor_state cstate;
464    vlVdpOutputSurface *last_surf;
465 } vlVdpPresentationQueue;
466 
467 typedef struct
468 {
469    vlVdpDevice *device;
470    mtx_t mutex;
471    struct pipe_video_codec *decoder;
472 } vlVdpDecoder;
473 
474 typedef uint32_t vlHandle;
475 
476 boolean vlCreateHTAB(void);
477 void vlDestroyHTAB(void);
478 vlHandle vlAddDataHTAB(void *data);
479 void* vlGetDataHTAB(vlHandle handle);
480 void vlRemoveDataHTAB(vlHandle handle);
481 
482 boolean vlGetFuncFTAB(VdpFuncId function_id, void **func);
483 
484 /* Public functions */
485 VdpDeviceCreateX11 vdp_imp_device_create_x11;
486 
487 void vlVdpDefaultSamplerViewTemplate(struct pipe_sampler_view *templ, struct pipe_resource *res);
488 
489 /* Internal function pointers */
490 VdpGetErrorString vlVdpGetErrorString;
491 VdpDeviceDestroy vlVdpDeviceDestroy;
492 void vlVdpDeviceFree(vlVdpDevice *dev);
493 VdpGetProcAddress vlVdpGetProcAddress;
494 VdpGetApiVersion vlVdpGetApiVersion;
495 VdpGetInformationString vlVdpGetInformationString;
496 VdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities;
497 VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities;
498 VdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities;
499 VdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities;
500 VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities;
501 VdpOutputSurfaceQueryPutBitsIndexedCapabilities vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities;
502 VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities;
503 VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities;
504 VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport;
505 VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport;
506 VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange;
507 VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport;
508 VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange;
509 VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate;
510 VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy;
511 VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters;
512 VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr;
513 VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr;
514 void vlVdpVideoSurfaceClear(vlVdpSurface *vlsurf);
515 VdpDecoderCreate vlVdpDecoderCreate;
516 VdpDecoderDestroy vlVdpDecoderDestroy;
517 VdpDecoderGetParameters vlVdpDecoderGetParameters;
518 VdpDecoderRender vlVdpDecoderRender;
519 VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate;
520 VdpOutputSurfaceDestroy vlVdpOutputSurfaceDestroy;
521 VdpOutputSurfaceGetParameters vlVdpOutputSurfaceGetParameters;
522 VdpOutputSurfaceGetBitsNative vlVdpOutputSurfaceGetBitsNative;
523 VdpOutputSurfacePutBitsNative vlVdpOutputSurfacePutBitsNative;
524 VdpOutputSurfacePutBitsIndexed vlVdpOutputSurfacePutBitsIndexed;
525 VdpOutputSurfacePutBitsYCbCr vlVdpOutputSurfacePutBitsYCbCr;
526 VdpOutputSurfaceRenderOutputSurface vlVdpOutputSurfaceRenderOutputSurface;
527 VdpOutputSurfaceRenderBitmapSurface vlVdpOutputSurfaceRenderBitmapSurface;
528 VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate;
529 VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy;
530 VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters;
531 VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative;
532 VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy;
533 VdpPresentationQueueCreate vlVdpPresentationQueueCreate;
534 VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy;
535 VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor;
536 VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor;
537 VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime;
538 VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay;
539 VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle;
540 VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus;
541 VdpPreemptionCallback vlVdpPreemptionCallback;
542 VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister;
543 VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables;
544 VdpVideoMixerCreate vlVdpVideoMixerCreate;
545 VdpVideoMixerRender vlVdpVideoMixerRender;
546 VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues;
547 VdpVideoMixerGetFeatureSupport vlVdpVideoMixerGetFeatureSupport;
548 VdpVideoMixerGetFeatureEnables vlVdpVideoMixerGetFeatureEnables;
549 VdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues;
550 VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues;
551 VdpVideoMixerDestroy vlVdpVideoMixerDestroy;
552 VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix;
553 /* Winsys specific internal function pointers */
554 VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11;
555 
556 
557 /* interop for GL gallium frontend */
558 VdpVideoSurfaceGallium vlVdpVideoSurfaceGallium;
559 VdpOutputSurfaceGallium vlVdpOutputSurfaceGallium;
560 VdpVideoSurfaceDMABuf vlVdpVideoSurfaceDMABuf;
561 VdpOutputSurfaceDMABuf vlVdpOutputSurfaceDMABuf;
562 
563 #define VDPAU_OUT   0
564 #define VDPAU_ERR   1
565 #define VDPAU_WARN  2
566 #define VDPAU_TRACE 3
567 
VDPAU_MSG(unsigned int level,const char * fmt,...)568 static inline void VDPAU_MSG(unsigned int level, const char *fmt, ...)
569 {
570    static int debug_level = -1;
571 
572    if (debug_level == -1) {
573       debug_level = MAX2(debug_get_num_option("VDPAU_DEBUG", 0), 0);
574    }
575 
576    if (level <= debug_level) {
577       va_list ap;
578       va_start(ap, fmt);
579       _debug_vprintf(fmt, ap);
580       va_end(ap);
581    }
582 }
583 
584 static inline void
DeviceReference(vlVdpDevice ** ptr,vlVdpDevice * dev)585 DeviceReference(vlVdpDevice **ptr, vlVdpDevice *dev)
586 {
587    vlVdpDevice *old_dev = *ptr;
588 
589    if (pipe_reference(&(*ptr)->reference, &dev->reference))
590       vlVdpDeviceFree(old_dev);
591    *ptr = dev;
592 }
593 
594 #endif /* VDPAU_PRIVATE_H */
595