Path: blob/21.2-virgl/src/gallium/frontends/vdpau/vdpau_private.h
4565 views
/**************************************************************************1*2* Copyright 2010 Younes Manton & Thomas Balling Sørensen.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#ifndef VDPAU_PRIVATE_H28#define VDPAU_PRIVATE_H2930#include <assert.h>3132#include <vdpau/vdpau.h>33#include <vdpau/vdpau_x11.h>3435#include "pipe/p_compiler.h"36#include "pipe/p_video_codec.h"3738#include "frontend/vdpau_interop.h"39#include "frontend/vdpau_dmabuf.h"40#include "frontend/vdpau_funcs.h"4142#include "util/u_debug.h"43#include "util/u_rect.h"44#include "os/os_thread.h"4546#include "vl/vl_video_buffer.h"47#include "vl/vl_bicubic_filter.h"48#include "vl/vl_compositor.h"49#include "vl/vl_csc.h"50#include "vl/vl_deint_filter.h"51#include "vl/vl_matrix_filter.h"52#include "vl/vl_median_filter.h"53#include "vl/vl_winsys.h"5455/* Full VDPAU API documentation available at :56* ftp://download.nvidia.com/XFree86/vdpau/doxygen/html/index.html */5758#define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR59#define QUOTEME(x) #x60#define TOSTRING(x) QUOTEME(x)61#define INFORMATION_STRING TOSTRING(INFORMATION)6263static inline enum pipe_video_chroma_format64ChromaToPipe(VdpChromaType vdpau_type)65{66switch (vdpau_type) {67case VDP_CHROMA_TYPE_420:68return PIPE_VIDEO_CHROMA_FORMAT_420;69case VDP_CHROMA_TYPE_422:70return PIPE_VIDEO_CHROMA_FORMAT_422;71case VDP_CHROMA_TYPE_444:72return PIPE_VIDEO_CHROMA_FORMAT_444;73default:74assert(0);75}7677return -1;78}7980static inline VdpChromaType81PipeToChroma(enum pipe_video_chroma_format pipe_type)82{83switch (pipe_type) {84case PIPE_VIDEO_CHROMA_FORMAT_420:85return VDP_CHROMA_TYPE_420;86case PIPE_VIDEO_CHROMA_FORMAT_422:87return VDP_CHROMA_TYPE_422;88case PIPE_VIDEO_CHROMA_FORMAT_444:89return VDP_CHROMA_TYPE_444;90default:91assert(0);92}9394return -1;95}9697static inline enum pipe_video_chroma_format98FormatYCBCRToPipeChroma(VdpYCbCrFormat vdpau_format)99{100switch (vdpau_format) {101case VDP_YCBCR_FORMAT_NV12:102return PIPE_VIDEO_CHROMA_FORMAT_420;103case VDP_YCBCR_FORMAT_YV12:104return PIPE_VIDEO_CHROMA_FORMAT_420;105case VDP_YCBCR_FORMAT_UYVY:106return PIPE_VIDEO_CHROMA_FORMAT_422;107case VDP_YCBCR_FORMAT_YUYV:108return PIPE_VIDEO_CHROMA_FORMAT_422;109case VDP_YCBCR_FORMAT_Y8U8V8A8:110return PIPE_VIDEO_CHROMA_FORMAT_444;111case VDP_YCBCR_FORMAT_V8U8Y8A8:112return PIPE_VIDEO_CHROMA_FORMAT_444;113default:114assert(0);115}116117return PIPE_VIDEO_CHROMA_FORMAT_NONE;118}119120static inline enum pipe_format121FormatYCBCRToPipe(VdpYCbCrFormat vdpau_format)122{123switch (vdpau_format) {124case VDP_YCBCR_FORMAT_NV12:125return PIPE_FORMAT_NV12;126case VDP_YCBCR_FORMAT_YV12:127return PIPE_FORMAT_YV12;128case VDP_YCBCR_FORMAT_UYVY:129return PIPE_FORMAT_UYVY;130case VDP_YCBCR_FORMAT_YUYV:131return PIPE_FORMAT_YUYV;132case VDP_YCBCR_FORMAT_Y8U8V8A8:133return PIPE_FORMAT_R8G8B8A8_UNORM;134case VDP_YCBCR_FORMAT_V8U8Y8A8:135return PIPE_FORMAT_B8G8R8A8_UNORM;136#ifdef VDP_YCBCR_FORMAT_P010137case VDP_YCBCR_FORMAT_P010:138return PIPE_FORMAT_P010;139#endif140#ifdef VDP_YCBCR_FORMAT_P016141case VDP_YCBCR_FORMAT_P016:142return PIPE_FORMAT_P016;143#endif144default:145/* NOTE: Can't be "unreachable", as it's quite reachable. */146debug_assert(!"unexpected VdpYCbCrFormat");147#if defined(NDEBUG) || defined(DEBUG)148FALLTHROUGH;149#endif150#ifdef VDP_YCBCR_FORMAT_Y_UV_444151case VDP_YCBCR_FORMAT_Y_UV_444:152#endif153#ifdef VDP_YCBCR_FORMAT_Y_U_V_444154case VDP_YCBCR_FORMAT_Y_U_V_444:155#endif156#ifdef VDP_YCBCR_FORMAT_Y_U_V_444_16157case VDP_YCBCR_FORMAT_Y_U_V_444_16:158#endif159return PIPE_FORMAT_NONE;160}161162}163164static inline VdpYCbCrFormat165PipeToFormatYCBCR(enum pipe_format p_format)166{167switch (p_format) {168case PIPE_FORMAT_NV12:169return VDP_YCBCR_FORMAT_NV12;170case PIPE_FORMAT_YV12:171return VDP_YCBCR_FORMAT_YV12;172case PIPE_FORMAT_UYVY:173return VDP_YCBCR_FORMAT_UYVY;174case PIPE_FORMAT_YUYV:175return VDP_YCBCR_FORMAT_YUYV;176case PIPE_FORMAT_R8G8B8A8_UNORM:177return VDP_YCBCR_FORMAT_Y8U8V8A8;178case PIPE_FORMAT_B8G8R8A8_UNORM:179return VDP_YCBCR_FORMAT_V8U8Y8A8;180default:181assert(0);182}183184return -1;185}186187static inline VdpRGBAFormat188PipeToFormatRGBA(enum pipe_format p_format)189{190switch (p_format) {191case PIPE_FORMAT_A8_UNORM:192return VDP_RGBA_FORMAT_A8;193case PIPE_FORMAT_B10G10R10A2_UNORM:194return VDP_RGBA_FORMAT_B10G10R10A2;195case PIPE_FORMAT_B8G8R8A8_UNORM:196return VDP_RGBA_FORMAT_B8G8R8A8;197case PIPE_FORMAT_R10G10B10A2_UNORM:198return VDP_RGBA_FORMAT_R10G10B10A2;199case PIPE_FORMAT_R8G8B8A8_UNORM:200return VDP_RGBA_FORMAT_R8G8B8A8;201default:202assert(0);203}204205return -1;206}207208static inline enum pipe_format209FormatIndexedToPipe(VdpRGBAFormat vdpau_format)210{211switch (vdpau_format) {212case VDP_INDEXED_FORMAT_A4I4:213return PIPE_FORMAT_R4A4_UNORM;214case VDP_INDEXED_FORMAT_I4A4:215return PIPE_FORMAT_A4R4_UNORM;216case VDP_INDEXED_FORMAT_A8I8:217return PIPE_FORMAT_A8R8_UNORM;218case VDP_INDEXED_FORMAT_I8A8:219return PIPE_FORMAT_R8A8_UNORM;220default:221assert(0);222}223224return PIPE_FORMAT_NONE;225}226227static inline enum pipe_format228FormatColorTableToPipe(VdpColorTableFormat vdpau_format)229{230switch(vdpau_format) {231case VDP_COLOR_TABLE_FORMAT_B8G8R8X8:232return PIPE_FORMAT_B8G8R8X8_UNORM;233default:234assert(0);235}236237return PIPE_FORMAT_NONE;238}239240static inline enum pipe_video_profile241ProfileToPipe(VdpDecoderProfile vdpau_profile)242{243switch (vdpau_profile) {244case VDP_DECODER_PROFILE_MPEG1:245return PIPE_VIDEO_PROFILE_MPEG1;246case VDP_DECODER_PROFILE_MPEG2_SIMPLE:247return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE;248case VDP_DECODER_PROFILE_MPEG2_MAIN:249return PIPE_VIDEO_PROFILE_MPEG2_MAIN;250case VDP_DECODER_PROFILE_H264_BASELINE:251return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE;252case VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE:253return PIPE_VIDEO_PROFILE_MPEG4_AVC_CONSTRAINED_BASELINE;254case VDP_DECODER_PROFILE_H264_MAIN:255return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN;256case VDP_DECODER_PROFILE_H264_HIGH:257return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;258case VDP_DECODER_PROFILE_MPEG4_PART2_SP:259return PIPE_VIDEO_PROFILE_MPEG4_SIMPLE;260case VDP_DECODER_PROFILE_MPEG4_PART2_ASP:261return PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE;262case VDP_DECODER_PROFILE_VC1_SIMPLE:263return PIPE_VIDEO_PROFILE_VC1_SIMPLE;264case VDP_DECODER_PROFILE_VC1_MAIN:265return PIPE_VIDEO_PROFILE_VC1_MAIN;266case VDP_DECODER_PROFILE_VC1_ADVANCED:267return PIPE_VIDEO_PROFILE_VC1_ADVANCED;268case VDP_DECODER_PROFILE_HEVC_MAIN:269return PIPE_VIDEO_PROFILE_HEVC_MAIN;270case VDP_DECODER_PROFILE_HEVC_MAIN_10:271return PIPE_VIDEO_PROFILE_HEVC_MAIN_10;272case VDP_DECODER_PROFILE_HEVC_MAIN_STILL:273return PIPE_VIDEO_PROFILE_HEVC_MAIN_STILL;274case VDP_DECODER_PROFILE_HEVC_MAIN_12:275return PIPE_VIDEO_PROFILE_HEVC_MAIN_12;276case VDP_DECODER_PROFILE_HEVC_MAIN_444:277return PIPE_VIDEO_PROFILE_HEVC_MAIN_444;278default:279return PIPE_VIDEO_PROFILE_UNKNOWN;280}281}282283static inline VdpDecoderProfile284PipeToProfile(enum pipe_video_profile p_profile)285{286switch (p_profile) {287case PIPE_VIDEO_PROFILE_MPEG1:288return VDP_DECODER_PROFILE_MPEG1;289case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:290return VDP_DECODER_PROFILE_MPEG2_SIMPLE;291case PIPE_VIDEO_PROFILE_MPEG2_MAIN:292return VDP_DECODER_PROFILE_MPEG2_MAIN;293case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE:294return VDP_DECODER_PROFILE_H264_BASELINE;295case PIPE_VIDEO_PROFILE_MPEG4_AVC_CONSTRAINED_BASELINE:296return VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE;297case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN:298return VDP_DECODER_PROFILE_H264_MAIN;299case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH:300return VDP_DECODER_PROFILE_H264_HIGH;301case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE:302return VDP_DECODER_PROFILE_MPEG4_PART2_SP;303case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE:304return VDP_DECODER_PROFILE_MPEG4_PART2_ASP;305case PIPE_VIDEO_PROFILE_VC1_SIMPLE:306return VDP_DECODER_PROFILE_VC1_SIMPLE;307case PIPE_VIDEO_PROFILE_VC1_MAIN:308return VDP_DECODER_PROFILE_VC1_MAIN;309case PIPE_VIDEO_PROFILE_VC1_ADVANCED:310return VDP_DECODER_PROFILE_VC1_ADVANCED;311case PIPE_VIDEO_PROFILE_HEVC_MAIN:312return VDP_DECODER_PROFILE_HEVC_MAIN;313case PIPE_VIDEO_PROFILE_HEVC_MAIN_10:314return VDP_DECODER_PROFILE_HEVC_MAIN_10;315case PIPE_VIDEO_PROFILE_HEVC_MAIN_STILL:316return VDP_DECODER_PROFILE_HEVC_MAIN_STILL;317case PIPE_VIDEO_PROFILE_HEVC_MAIN_12:318return VDP_DECODER_PROFILE_HEVC_MAIN_12;319case PIPE_VIDEO_PROFILE_HEVC_MAIN_444:320return VDP_DECODER_PROFILE_HEVC_MAIN_444;321default:322assert(0);323return -1;324}325}326327static inline struct u_rect *328RectToPipe(const VdpRect *src, struct u_rect *dst)329{330if (src) {331dst->x0 = src->x0;332dst->y0 = src->y0;333dst->x1 = src->x1;334dst->y1 = src->y1;335return dst;336}337return NULL;338}339340static inline struct pipe_box341RectToPipeBox(const VdpRect *rect, struct pipe_resource *res)342{343struct pipe_box box;344345box.x = 0;346box.y = 0;347box.z = 0;348box.width = res->width0;349box.height = res->height0;350box.depth = 1;351352if (rect) {353if (rect->x1 > rect->x0 &&354rect->y1 > rect->y0) {355box.x = rect->x0;356box.y = rect->y0;357box.width = rect->x1 - box.x;358box.height = rect->y1 - box.y;359} else {360box.width = 0;361box.height = 0;362}363}364365return box;366}367368static inline bool369CheckSurfaceParams(struct pipe_screen *screen,370const struct pipe_resource *templ)371{372return screen->is_format_supported(screen, templ->format, templ->target,373templ->nr_samples,374templ->nr_storage_samples, templ->bind);375}376377typedef struct378{379struct pipe_reference reference;380struct vl_screen *vscreen;381struct pipe_context *context;382struct vl_compositor compositor;383struct pipe_sampler_view *dummy_sv;384mtx_t mutex;385} vlVdpDevice;386387typedef struct388{389vlVdpDevice *device;390struct vl_compositor_state cstate;391392struct {393bool supported, enabled;394float luma_min, luma_max;395} luma_key;396397struct {398bool supported, enabled, spatial;399struct vl_deint_filter *filter;400} deint;401402struct {403bool supported, enabled;404struct vl_bicubic_filter *filter;405} bicubic;406407struct {408bool supported, enabled;409unsigned level;410struct vl_median_filter *filter;411} noise_reduction;412413struct {414bool supported, enabled;415float value;416struct vl_matrix_filter *filter;417} sharpness;418419unsigned video_width, video_height;420enum pipe_video_chroma_format chroma_format;421unsigned max_layers, skip_chroma_deint;422423bool custom_csc;424vl_csc_matrix csc;425} vlVdpVideoMixer;426427typedef struct428{429vlVdpDevice *device;430struct pipe_video_buffer templat, *video_buffer;431} vlVdpSurface;432433typedef struct434{435vlVdpDevice *device;436struct pipe_sampler_view *sampler_view;437} vlVdpBitmapSurface;438439typedef uint64_t vlVdpTime;440441typedef struct442{443vlVdpDevice *device;444struct pipe_surface *surface;445struct pipe_sampler_view *sampler_view;446struct pipe_fence_handle *fence;447struct vl_compositor_state cstate;448struct u_rect dirty_area;449bool send_to_X;450} vlVdpOutputSurface;451452typedef struct453{454vlVdpDevice *device;455Drawable drawable;456} vlVdpPresentationQueueTarget;457458typedef struct459{460vlVdpDevice *device;461Drawable drawable;462struct vl_compositor_state cstate;463vlVdpOutputSurface *last_surf;464} vlVdpPresentationQueue;465466typedef struct467{468vlVdpDevice *device;469mtx_t mutex;470struct pipe_video_codec *decoder;471} vlVdpDecoder;472473typedef uint32_t vlHandle;474475boolean vlCreateHTAB(void);476void vlDestroyHTAB(void);477vlHandle vlAddDataHTAB(void *data);478void* vlGetDataHTAB(vlHandle handle);479void vlRemoveDataHTAB(vlHandle handle);480481boolean vlGetFuncFTAB(VdpFuncId function_id, void **func);482483/* Public functions */484VdpDeviceCreateX11 vdp_imp_device_create_x11;485486void vlVdpDefaultSamplerViewTemplate(struct pipe_sampler_view *templ, struct pipe_resource *res);487488/* Internal function pointers */489VdpGetErrorString vlVdpGetErrorString;490VdpDeviceDestroy vlVdpDeviceDestroy;491void vlVdpDeviceFree(vlVdpDevice *dev);492VdpGetProcAddress vlVdpGetProcAddress;493VdpGetApiVersion vlVdpGetApiVersion;494VdpGetInformationString vlVdpGetInformationString;495VdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities;496VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities;497VdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities;498VdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities;499VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities;500VdpOutputSurfaceQueryPutBitsIndexedCapabilities vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities;501VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities;502VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities;503VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport;504VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport;505VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange;506VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport;507VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange;508VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate;509VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy;510VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters;511VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr;512VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr;513void vlVdpVideoSurfaceClear(vlVdpSurface *vlsurf);514VdpDecoderCreate vlVdpDecoderCreate;515VdpDecoderDestroy vlVdpDecoderDestroy;516VdpDecoderGetParameters vlVdpDecoderGetParameters;517VdpDecoderRender vlVdpDecoderRender;518VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate;519VdpOutputSurfaceDestroy vlVdpOutputSurfaceDestroy;520VdpOutputSurfaceGetParameters vlVdpOutputSurfaceGetParameters;521VdpOutputSurfaceGetBitsNative vlVdpOutputSurfaceGetBitsNative;522VdpOutputSurfacePutBitsNative vlVdpOutputSurfacePutBitsNative;523VdpOutputSurfacePutBitsIndexed vlVdpOutputSurfacePutBitsIndexed;524VdpOutputSurfacePutBitsYCbCr vlVdpOutputSurfacePutBitsYCbCr;525VdpOutputSurfaceRenderOutputSurface vlVdpOutputSurfaceRenderOutputSurface;526VdpOutputSurfaceRenderBitmapSurface vlVdpOutputSurfaceRenderBitmapSurface;527VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate;528VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy;529VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters;530VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative;531VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy;532VdpPresentationQueueCreate vlVdpPresentationQueueCreate;533VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy;534VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor;535VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor;536VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime;537VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay;538VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle;539VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus;540VdpPreemptionCallback vlVdpPreemptionCallback;541VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister;542VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables;543VdpVideoMixerCreate vlVdpVideoMixerCreate;544VdpVideoMixerRender vlVdpVideoMixerRender;545VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues;546VdpVideoMixerGetFeatureSupport vlVdpVideoMixerGetFeatureSupport;547VdpVideoMixerGetFeatureEnables vlVdpVideoMixerGetFeatureEnables;548VdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues;549VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues;550VdpVideoMixerDestroy vlVdpVideoMixerDestroy;551VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix;552/* Winsys specific internal function pointers */553VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11;554555556/* interop for GL gallium frontend */557VdpVideoSurfaceGallium vlVdpVideoSurfaceGallium;558VdpOutputSurfaceGallium vlVdpOutputSurfaceGallium;559VdpVideoSurfaceDMABuf vlVdpVideoSurfaceDMABuf;560VdpOutputSurfaceDMABuf vlVdpOutputSurfaceDMABuf;561562#define VDPAU_OUT 0563#define VDPAU_ERR 1564#define VDPAU_WARN 2565#define VDPAU_TRACE 3566567static inline void VDPAU_MSG(unsigned int level, const char *fmt, ...)568{569static int debug_level = -1;570571if (debug_level == -1) {572debug_level = MAX2(debug_get_num_option("VDPAU_DEBUG", 0), 0);573}574575if (level <= debug_level) {576va_list ap;577va_start(ap, fmt);578_debug_vprintf(fmt, ap);579va_end(ap);580}581}582583static inline void584DeviceReference(vlVdpDevice **ptr, vlVdpDevice *dev)585{586vlVdpDevice *old_dev = *ptr;587588if (pipe_reference(&(*ptr)->reference, &dev->reference))589vlVdpDeviceFree(old_dev);590*ptr = dev;591}592593#endif /* VDPAU_PRIVATE_H */594595596