1 diff --git a/Makefile.am b/Makefile.am
2 index a733b52..bc315df 100644
6 # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
7 # PERFORMANCE OF THIS SOFTWARE.
10 +SUBDIRS = src include wrapper
12 pkgconfigdir = $(libdir)/pkgconfig
13 pkgconfig_DATA = xvmc.pc
14 diff --git a/configure.ac b/configure.ac
15 index 6a904dd..5fb8113 100644
19 -dnl Copyright 2005 Red Hat, Inc.
21 -dnl Permission to use, copy, modify, distribute, and sell this software and its
22 -dnl documentation for any purpose is hereby granted without fee, provided that
23 -dnl the above copyright notice appear in all copies and that both that
24 -dnl copyright notice and this permission notice appear in supporting
25 -dnl documentation, and that the name of Red Hat not be used in
26 -dnl advertising or publicity pertaining to distribution of the software without
27 -dnl specific, written prior permission. Red Hat makes no
28 -dnl representations about the suitability of this software for any purpose. It
29 -dnl is provided "as is" without express or implied warranty.
31 -dnl RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
32 -dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
33 -dnl EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
34 -dnl CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
35 -dnl DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
36 -dnl TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
37 -dnl PERFORMANCE OF THIS SOFTWARE.
39 -dnl Process this file with autoconf to create configure.
41 +# Copyright 2005 Red Hat, Inc.
43 +# Permission to use, copy, modify, distribute, and sell this software and its
44 +# documentation for any purpose is hereby granted without fee, provided that
45 +# the above copyright notice appear in all copies and that both that
46 +# copyright notice and this permission notice appear in supporting
47 +# documentation, and that the name of Red Hat not be used in
48 +# advertising or publicity pertaining to distribution of the software without
49 +# specific, written prior permission. Red Hat makes no
50 +# representations about the suitability of this software for any purpose. It
51 +# is provided "as is" without express or implied warranty.
53 +# RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
54 +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
55 +# EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
56 +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
57 +# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
58 +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
59 +# PERFORMANCE OF THIS SOFTWARE.
62 +# Initialize Autoconf
64 +AC_INIT([libXvMC], [1.0.6],
65 + [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXvMC])
66 +AC_CONFIG_SRCDIR([Makefile.am])
67 +AC_CONFIG_HEADERS([config.h])
71 - [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
73 +# Initialize Automake
74 AM_INIT_AUTOMAKE([foreign dist-bzip2])
77 -# Require xorg-macros: XORG_DEFAULT_OPTIONS
81 +# Require X.Org macros 1.8 or later for AC_PROG_INSTALL
82 m4_ifndef([XORG_MACROS_VERSION],
83 - [m4_fatal([must install xorg-macros 1.3 or later before running autoconf/autogen])])
84 -XORG_MACROS_VERSION(1.3)
85 + [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
86 +XORG_MACROS_VERSION(1.8)
88 -AM_CONFIG_HEADER(config.h)
92 +XORG_CHECK_MALLOC_ZERO
94 -# Check for dependencies
95 +# Obtain compiler/linker options for depedencies
96 PKG_CHECK_MODULES(XVMC, x11 xext xv xextproto videoproto)
98 -AC_CHECK_FUNC([shmat], AC_DEFINE(HAS_SHM,1,[Has shm*() functions]))
99 +# Checks for library functions.
100 +AC_CHECK_FUNCS([shmat])
102 -XORG_CHECK_MALLOC_ZERO
104 -dnl Allow checking code with lint, sparse, etc.
105 +# Allow checking code with lint, sparse, etc.
107 LINT_FLAGS="${LINT_FLAGS} ${XVMC_CFLAGS}"
112 - include/X11/Makefile
113 - include/X11/extensions/Makefile
116 +AC_CONFIG_FILES([Makefile
118 + include/X11/Makefile
119 + include/X11/extensions/Makefile
124 diff --git a/src/Makefile.am b/src/Makefile.am
125 index 741e7c5..05284fe 100644
126 --- a/src/Makefile.am
127 +++ b/src/Makefile.am
129 -lib_LTLIBRARIES = libXvMC.la libXvMCW.la
130 +lib_LTLIBRARIES = libXvMC.la
132 -libXvMC_la_SOURCES = \
136 -libXvMCW_la_SOURCES = \
139 -AM_CFLAGS = $(CWARNFLAGS) @XVMC_CFLAGS@
140 -AM_CPPFLAGS = -I$(top_srcdir)/include @MALLOC_ZERO_CFLAGS@
142 -libXvMC_la_LIBADD = @XVMC_LIBS@
143 -libXvMC_la_CFLAGS = $(AM_CFLAGS)
145 -libXvMCW_la_LIBADD = @XVMC_LIBS@
146 -libXvMCW_la_CFLAGS = \
148 - -DXVMC_CONFIGDIR=$(sysconfdir)/X11 \
149 - -DXVMC_SOVERSION=\".1.0\" \
150 - -DXV_SOVERSION=\".1.0\"
151 +AM_CPPFLAGS = -I$(top_srcdir)/include $(MALLOC_ZERO_CFLAGS)
152 +AM_CFLAGS = $(CWARNFLAGS) $(XVMC_CFLAGS)
154 +libXvMC_la_SOURCES = XvMC.c XvMClibint.h
155 +libXvMC_la_LIBADD = $(XVMC_LIBS)
156 libXvMC_la_LDFLAGS = -version-number 1:0:0 -no-undefined
157 -libXvMCW_la_LDFLAGS = -version-number 1:0:0 -no-undefined
161 -ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
162 +ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) \
163 $(AM_CPPFLAGS) $(CPPFLAGS)
166 - $(LINT) $(ALL_LINT_FLAGS) $(libXvMC_la_SOURCES) $(XVMC_LIBS)
167 - $(LINT) $(ALL_LINT_FLAGS) $(libXvMCW_la_CFLAGS) $(libXvMCW_la_SOURCES) $(XVMC_LIBS)
168 + $(LINT) $(ALL_LINT_FLAGS) $(libXvMC_la_SOURCES) $(AM_CFLAGS) $(XVMC_LIBS)
170 diff --git a/src/XvMC.c b/src/XvMC.c
171 index 3bf5a43..eb8e7e8 100644
177 #include "XvMClibint.h"
187 -#endif /* HAS_SHM */
188 +#endif /* HAVE_SHMAT */
190 #include <sys/time.h>
191 #include <X11/extensions/Xext.h>
192 @@ -487,7 +487,7 @@ Status XvMCGetDRInfo(Display *dpy, XvPortID port,
198 volatile CARD32 *shMem;
199 struct timezone here;
201 @@ -503,7 +503,7 @@ Status XvMCGetDRInfo(Display *dpy, XvPortID port,
207 req->shmKey = shmget(IPC_PRIVATE, 1024, IPC_CREAT | 0600);
210 @@ -541,14 +541,14 @@ Status XvMCGetDRInfo(Display *dpy, XvPortID port,
211 if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
216 if ( req->shmKey >= 0) {
217 shmdt( (const void *) shMem );
224 shmdt( (const void *) shMem );
227 diff --git a/src/XvMCWrapper.c b/src/XvMCWrapper.c
228 deleted file mode 100644
229 index d3800e7..0000000
230 --- a/src/XvMCWrapper.c
233 -/*****************************************************************************
234 - * XvMC Wrapper including the Nonstandard VLD extension.
236 - * Copyright (c) 2004 The Unichrome project. All rights reserved.
239 - * Permission is hereby granted, free of charge, to any person obtaining a
240 - * copy of this software and associated documentation files (the "Software"),
241 - * to deal in the Software without restriction, including without limitation
242 - * the rights to use, copy, modify, merge, publish, distribute, sublicense,
243 - * and/or sell copies of the Software, and to permit persons to whom the
244 - * Software is furnished to do so, subject to the following conditions:
246 - * The above copyright notice and this permission notice shall be included in
247 - * all copies or substantial portions of the Software.
249 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
250 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
251 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
252 - * AUTHOR(S) OR COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
253 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
254 - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
255 - * DEALINGS IN THE SOFTWARE.
257 - * Author: Thomas Hellström (2004)
261 - * BUGS: The wrapper really should maintain one symbol table per port. This
262 - * could possibly be impemented, To do that, the port-independent symbols need to be lifted out,
263 - * and one would have to create a number of mapping tables:
265 - * port -> symbol table
268 - * subpicture -> port
270 - * and reference the right table when needed.
271 - * This needs to be done only if there is a player that wants to access two displays with different
272 - * hardware simultaneously. Not likely as of today.
275 -#ifdef HAVE_CONFIG_H
276 - #include "config.h"
279 -#include <X11/Xlib.h>
280 -#include <X11/extensions/XvMC.h>
281 -#include <X11/extensions/XvMClib.h>
282 -#include <X11/extensions/vldXvMC.h>
290 -typedef Bool (*XvMCQueryExtensionP) (Display *, int *, int *);
291 -typedef Status (*XvMCQueryVersionP) (Display *, int *,int *);
292 -typedef XvMCSurfaceInfo * (*XvMCListSurfaceTypesP)(Display *, XvPortID, int *);
293 -typedef Status (* XvMCCreateContextP) (Display *,XvPortID,int ,int ,int ,int ,XvMCContext * );
294 -typedef Status (*XvMCDestroyContextP) (Display *, XvMCContext * );
295 -typedef Status (*XvMCCreateSurfaceP)(Display *,XvMCContext *,XvMCSurface *);
296 -typedef Status (*XvMCDestroySurfaceP)(Display *, XvMCSurface *);
297 -typedef XvImageFormatValues * (*XvMCListSubpictureTypesP) (Display *,XvPortID ,int ,int *);
298 -typedef Status (*XvMCPutSurfaceP)(Display *,XvMCSurface *,Drawable ,short , short , unsigned short ,
299 - unsigned short ,short ,short ,unsigned short ,unsigned short ,int );
300 -typedef Status (*XvMCHideSurfaceP)(Display *, XvMCSurface *);
301 -typedef Status (*XvMCCreateSubpictureP) (Display *, XvMCContext *, XvMCSubpicture *,
302 - unsigned short, unsigned short,int);
303 -typedef Status (*XvMCClearSubpictureP) (Display *,XvMCSubpicture *,short,short,unsigned short,unsigned short,
305 -typedef Status (*XvMCCompositeSubpictureP) (Display *, XvMCSubpicture *,XvImage *,short,short,
306 - unsigned short, unsigned short,short,short);
307 -typedef Status (*XvMCDestroySubpictureP) (Display *, XvMCSubpicture *);
308 -typedef Status (*XvMCSetSubpicturePaletteP) (Display *, XvMCSubpicture *, unsigned char *);
309 -typedef Status (*XvMCBlendSubpictureP) (Display *d,XvMCSurface *,XvMCSubpicture *,short,
310 - short,unsigned short,unsigned short,short,short,
311 - unsigned short,unsigned short);
312 -typedef Status (*XvMCBlendSubpicture2P) (Display *,XvMCSurface *,XvMCSurface *,
313 - XvMCSubpicture *,short,short,unsigned short,
314 - unsigned short,short,short,unsigned short,
316 -typedef Status (*XvMCSyncSurfaceP) (Display *, XvMCSurface *);
317 -typedef Status (*XvMCFlushSurfaceP) (Display *, XvMCSurface *);
318 -typedef Status (*XvMCGetSurfaceStatusP) (Display *, XvMCSurface *, int *);
319 -typedef Status (*XvMCRenderSurfaceP) (Display *,XvMCContext *,unsigned int,XvMCSurface *,
320 - XvMCSurface *,XvMCSurface *,unsigned int,unsigned int,
321 - unsigned int,XvMCMacroBlockArray *,XvMCBlockArray *);
322 -typedef Status (*XvMCSyncSubpictureP) (Display *, XvMCSubpicture *);
323 -typedef Status (*XvMCFlushSubpictureP) (Display *, XvMCSubpicture *);
324 -typedef Status (*XvMCGetSubpictureStatusP) (Display *, XvMCSubpicture *, int *);
325 -typedef Status (*XvMCCreateBlocksP) (Display *, XvMCContext *,unsigned int,XvMCBlockArray *);
326 -typedef Status (*XvMCDestroyBlocksP) (Display *,XvMCBlockArray *);
327 -typedef Status (*XvMCCreateMacroBlocksP) (Display *,XvMCContext *,unsigned int,
328 - XvMCMacroBlockArray *);
329 -typedef Status (*XvMCDestroyMacroBlocksP) (Display *,XvMCMacroBlockArray *);
330 -typedef XvAttribute *(*XvMCQueryAttributesP) (Display *,XvMCContext *,int *);
331 -typedef Status (*XvMCSetAttributeP) (Display *,XvMCContext *, Atom, int);
332 -typedef Status (*XvMCGetAttributeP) (Display *,XvMCContext *, Atom, int *);
335 - * Nonstandard VLD acceleration level:
338 -typedef Status (*XvMCBeginSurfaceP) (Display *,XvMCContext *,XvMCSurface *,
339 - XvMCSurface *,XvMCSurface *f,const XvMCMpegControl *);
340 -typedef Status (*XvMCLoadQMatrixP) (Display *, XvMCContext *,const XvMCQMatrix *);
341 -typedef Status (*XvMCPutSliceP)(Display *,XvMCContext *, char *,int);
342 -typedef Status (*XvMCPutSlice2P)(Display *,XvMCContext *, char *,int, unsigned);
343 -typedef Status (*XvMCGetDRInfoP)(Display *, XvPortID, char **, char **, int *, int *,
348 - XvMCQueryExtensionP XvMCQueryExtension;
349 - XvMCQueryVersionP XvMCQueryVersion;
350 - XvMCListSurfaceTypesP XvMCListSurfaceTypes;
351 - XvMCCreateContextP XvMCCreateContext;
352 - XvMCDestroyContextP XvMCDestroyContext;
353 - XvMCCreateSurfaceP XvMCCreateSurface;
354 - XvMCDestroySurfaceP XvMCDestroySurface;
355 - XvMCListSubpictureTypesP XvMCListSubpictureTypes;
356 - XvMCPutSurfaceP XvMCPutSurface;
357 - XvMCHideSurfaceP XvMCHideSurface;
358 - XvMCCreateSubpictureP XvMCCreateSubpicture;
359 - XvMCClearSubpictureP XvMCClearSubpicture;
360 - XvMCCompositeSubpictureP XvMCCompositeSubpicture;
361 - XvMCDestroySubpictureP XvMCDestroySubpicture;
362 - XvMCSetSubpicturePaletteP XvMCSetSubpicturePalette;
363 - XvMCBlendSubpictureP XvMCBlendSubpicture;
364 - XvMCBlendSubpicture2P XvMCBlendSubpicture2;
365 - XvMCSyncSurfaceP XvMCSyncSurface;
366 - XvMCFlushSurfaceP XvMCFlushSurface;
367 - XvMCGetSurfaceStatusP XvMCGetSurfaceStatus;
368 - XvMCRenderSurfaceP XvMCRenderSurface;
369 - XvMCSyncSubpictureP XvMCSyncSubpicture;
370 - XvMCFlushSubpictureP XvMCFlushSubpicture;
371 - XvMCGetSubpictureStatusP XvMCGetSubpictureStatus;
372 - XvMCCreateBlocksP XvMCCreateBlocks;
373 - XvMCDestroyBlocksP XvMCDestroyBlocks;
374 - XvMCCreateMacroBlocksP XvMCCreateMacroBlocks;
375 - XvMCDestroyMacroBlocksP XvMCDestroyMacroBlocks;
376 - XvMCQueryAttributesP XvMCQueryAttributes;
377 - XvMCSetAttributeP XvMCSetAttribute;
378 - XvMCGetAttributeP XvMCGetAttribute;
381 - * Nonstandard VLD acceleration level:
384 - XvMCBeginSurfaceP XvMCBeginSurface;
385 - XvMCLoadQMatrixP XvMCLoadQMatrix;
386 - XvMCPutSliceP XvMCPutSlice;
387 - XvMCPutSlice2P XvMCPutSlice2;
390 - * Driver name function.
393 - XvMCGetDRInfoP XvMCGetDRInfo;
395 - int preInitialised;
400 -static XvMCWrapper xW;
401 -static int wrapperInit = 0;
402 -static int wrapperPreInit = 0;
403 -static void *xvhandle;
404 -static void *handle2;
408 -#define STRS(ARG) STR(ARG)
409 -#define STR(ARG) #ARG
411 -#define XW_RSYM(base,handle,handle2,pointer, retval) \
413 - register char *err; \
414 - base.pointer = (pointer##P) dlsym((handle),#pointer); \
415 - if ((err = dlerror()) != NULL) { \
417 - fprintf(stderr,"%s\n",err); return retval; \
419 - base.pointer = (pointer##P) dlsym((handle2),#pointer); \
420 - if ((err = dlerror()) != NULL) { \
421 - fprintf(stderr,"%s\n",err); return retval; \
426 -#define XW_RSYM2(base,handle,handle2,pointer) \
427 - base.pointer = (pointer##P) dlsym((handle),#pointer); \
428 - if (dlerror() != NULL) { \
429 - base.pointer = (pointer##P) dlsym((handle2),#pointer); \
430 - if (dlerror() != NULL) return; \
435 - * Try to dlopen a shared library, versionless first.
439 -static void *dlopenversion(const char *lib, const char *version, int flag)
447 - curLen = strlen(lib) + (verLen = strlen(version)) + 1;
448 - curName = (char *) malloc(curLen * sizeof(char));
449 - strncpy( curName, lib, curLen);
451 - if (NULL != (tail = strstr(version+1,"."))) {
452 - strncat( curName, version, tail - version);
454 - strncat( curName, version, verLen);
457 - ret = dlopen(curName, flag);
462 -static int preInitW(Display *dpy)
466 - * Resolve functions that are not hw driver specific.
469 - void *handleZ = NULL;
471 - wrapperPreInit = 1;
472 - xW.preInitialised = 0;
473 - xW.initialised = 0;
474 - xvhandle = dlopenversion("libXv.so", XV_SOVERSION, RTLD_LAZY | RTLD_GLOBAL);
476 - fprintf(stderr,"XvMCWrapper: Warning! Could not open shared "
477 - "library \"libXv.so" XV_SOVERSION "\"\nThis may cause relocation "
478 - "errors later.\nError was: \"%s\".\n",dlerror());
480 - handle2 = dlopenversion("libXvMC.so", XVMC_SOVERSION, RTLD_LAZY | RTLD_GLOBAL);
482 - fprintf(stderr,"XvMCWrapper: Could not load XvMC "
483 - "library \"libXvMC.so" XVMC_SOVERSION "\". Failing\n");
484 - fprintf(stderr,"%s\n",dlerror());
487 - XW_RSYM(xW, handle2, handleZ, XvMCQueryExtension, 1);
488 - XW_RSYM(xW, handle2, handleZ, XvMCQueryVersion, 1);
489 - xW.preInitialised = 1;
493 -static void initW(Display *dpy, XvPortID port)
495 - char nameBuffer[BUFLEN];
498 - char *clientName = NULL;
502 - int major,minor,patchLevel,isLocal;
503 - char *busID = NULL;
506 - xW.initialised = 0;
508 - if (!wrapperPreInit)
509 - if (preInitW( dpy )) return;
512 - * Will the DDX tell us the client driver name?
515 - xW.XvMCGetDRInfo = (XvMCGetDRInfoP)
516 - dlsym(handle2,"XvMCGetDRInfo");
518 - if ((err = dlerror()) == NULL) {
519 - if (0 == xW.XvMCGetDRInfo( dpy, port, &clientName, &busID, &major,
520 - &minor,&patchLevel, &isLocal)) {
521 - nameLen = strlen(clientName);
524 - fprintf(stderr,"XvMCWrapper: X server is not local. Cannot run XvMC.\n");
533 - if (clientName && (nameLen < BUFLEN-7) && (nameLen > 0)) {
535 - strncpy(nameBuffer,"lib",BUFLEN-1);
536 - strncpy(nameBuffer+3, clientName, BUFLEN-4);
537 - strncpy(nameBuffer + nameLen, ".so", BUFLEN-nameLen-1);
538 - nameBuffer[BUFLEN-1] = 0;
540 - handle = dlopenversion(nameBuffer, XVMC_SOVERSION,RTLD_LAZY);
543 - * No. Try to obtain it from the config file.
546 - if (clientName) XFree(clientName);
548 - configFile = fopen(STRS(XVMC_CONFIGDIR) "/XvMCConfig","r");
550 - xW.initialised = 0;
551 - xW.vldextension = 0;
553 - if (NULL == configFile) {
554 - fprintf(stderr,"XvMCWrapper: Could not open config file \"%s\".\n",
555 - STRS(XVMC_CONFIGDIR) "/XvMCConfig");
556 - perror("XvMCWrapper");
560 - if (NULL == fgets(nameBuffer, BUFLEN, configFile)) {
561 - fclose(configFile);
562 - fprintf(stderr,"XvMCWrapper: Could not read XvMC library name.\n");
563 - perror("XvMCWrapper");
567 - fclose(configFile);
568 - if ((tmp = strlen(nameBuffer)) == 0) {
569 - fprintf(stderr,"XvMCWrapper: Zero length XvMC library name.\n");
570 - fprintf(stderr,"%s\n",dlerror());
575 - * Skip trailing newlines and garbage.
578 - while (iscntrl(nameBuffer[tmp-1])) {
579 - nameBuffer[tmp-1] = 0;
581 - fprintf(stderr,"XvMCWrapper: Zero length XvMC library name.\n");
585 - handle = dlopen(nameBuffer,RTLD_LAZY);
588 - fprintf(stderr,"XvMCWrapper: Could not load hardware specific XvMC "
589 - "library \"%s\".\n",nameBuffer);
590 - fprintf(stderr,"%s\n",dlerror());
594 - XW_RSYM(xW, handle, handle2, XvMCListSurfaceTypes,);
595 - XW_RSYM(xW, handle, handle2, XvMCCreateContext,);
596 - XW_RSYM(xW, handle, handle2, XvMCDestroyContext,);
597 - XW_RSYM(xW, handle, handle2, XvMCCreateSurface,);
598 - XW_RSYM(xW, handle, handle2, XvMCDestroySurface,);
599 - XW_RSYM(xW, handle, handle2, XvMCListSubpictureTypes,);
600 - XW_RSYM(xW, handle, handle2, XvMCHideSurface,);
601 - XW_RSYM(xW, handle, handle2, XvMCCreateSubpicture,);
602 - XW_RSYM(xW, handle, handle2, XvMCClearSubpicture,);
603 - XW_RSYM(xW, handle, handle2, XvMCCompositeSubpicture,);
604 - XW_RSYM(xW, handle, handle2, XvMCDestroySubpicture,);
605 - XW_RSYM(xW, handle, handle2, XvMCSetSubpicturePalette,);
606 - XW_RSYM(xW, handle, handle2, XvMCBlendSubpicture,);
607 - XW_RSYM(xW, handle, handle2, XvMCBlendSubpicture2,);
608 - XW_RSYM(xW, handle, handle2, XvMCPutSurface,);
609 - XW_RSYM(xW, handle, handle2, XvMCSyncSurface,);
610 - XW_RSYM(xW, handle, handle2, XvMCFlushSurface,);
611 - XW_RSYM(xW, handle, handle2, XvMCGetSurfaceStatus,);
612 - XW_RSYM(xW, handle, handle2, XvMCRenderSurface,);
613 - XW_RSYM(xW, handle, handle2, XvMCSyncSubpicture,);
614 - XW_RSYM(xW, handle, handle2, XvMCFlushSubpicture,);
615 - XW_RSYM(xW, handle, handle2, XvMCGetSubpictureStatus,);
616 - XW_RSYM(xW, handle, handle2, XvMCCreateBlocks,);
617 - XW_RSYM(xW, handle, handle2, XvMCDestroyBlocks,);
618 - XW_RSYM(xW, handle, handle2, XvMCCreateMacroBlocks,);
619 - XW_RSYM(xW, handle, handle2, XvMCDestroyMacroBlocks,);
620 - XW_RSYM(xW, handle, handle2, XvMCQueryAttributes,);
621 - XW_RSYM(xW, handle, handle2, XvMCSetAttribute,);
622 - XW_RSYM(xW, handle, handle2, XvMCGetAttribute,);
623 - xW.initialised = 1;
624 - XW_RSYM2(xW, handle, handle2, XvMCBeginSurface);
625 - XW_RSYM(xW, handle, handle2, XvMCLoadQMatrix,);
626 - XW_RSYM(xW, handle, handle2, XvMCPutSlice,);
627 - XW_RSYM(xW, handle, handle2, XvMCPutSlice2,);
628 - xW.vldextension = 1;
632 -Bool XvMCQueryExtension (Display *display, int *eventBase, int *errBase)
634 - if (!wrapperPreInit) preInitW( display );
635 - if (!xW.preInitialised) return 0;
636 - return (*xW.XvMCQueryExtension)(display, eventBase, errBase);
639 -Status XvMCQueryVersion (Display *display, int *major_versionp,
640 - int *minor_versionp)
642 - if (!wrapperPreInit) preInitW( display );
643 - if (!xW.preInitialised) return 0;
644 - return (*xW.XvMCQueryVersion)(display, major_versionp, minor_versionp);
648 -XvMCSurfaceInfo * XvMCListSurfaceTypes(Display *dpy, XvPortID port, int *num)
650 - if (!wrapperInit) initW( dpy, port);
651 - if (!xW.initialised) return NULL;
652 - return (*xW.XvMCListSurfaceTypes)(dpy, port, num);
655 -Status XvMCCreateContext (
658 - int surface_type_id,
662 - XvMCContext * context
665 - if (!wrapperInit) initW(display, port);
666 - if (!xW.initialised) return BadValue;
667 - return (*xW.XvMCCreateContext)(display, port, surface_type_id,
668 - width, height, flags, context);
671 -Status XvMCDestroyContext (Display *display, XvMCContext * context)
673 - if (!xW.initialised) return BadValue;
674 - return (*xW.XvMCDestroyContext)(display, context);
680 - XvMCContext * context,
681 - XvMCSurface * surface
684 - if (!xW.initialised) return BadValue;
685 - return (*xW.XvMCCreateSurface)(display, context, surface);
688 -Status XvMCDestroySurface(Display *display, XvMCSurface *surface)
690 - if (!xW.initialised) return BadValue;
691 - return (*xW.XvMCDestroySurface)(display, surface);
695 -XvImageFormatValues * XvMCListSubpictureTypes (
698 - int surface_type_id,
702 - if (!xW.initialised) return NULL;
703 - return (*xW.XvMCListSubpictureTypes)(display, port, surface_type_id,
711 - XvMCSurface *surface,
715 - unsigned short srcw,
716 - unsigned short srch,
719 - unsigned short destw,
720 - unsigned short desth,
724 - if (!xW.initialised) return BadValue;
725 - return (*xW.XvMCPutSurface)(display, surface, draw, srcx, srcy, srcw, srch,
726 - destx, desty, destw, desth, flags);
729 -Status XvMCHideSurface(Display *display, XvMCSurface *surface)
731 - if (!xW.initialised) return BadValue;
732 - return (*xW.XvMCHideSurface)(display, surface);
737 -XvMCCreateSubpicture (
739 - XvMCContext *context,
740 - XvMCSubpicture *subpicture,
741 - unsigned short width,
742 - unsigned short height,
746 - if (!xW.initialised) return BadValue;
747 - return (*xW.XvMCCreateSubpicture)(display, context, subpicture, width, height,
753 -XvMCClearSubpicture (
755 - XvMCSubpicture *subpicture,
758 - unsigned short width,
759 - unsigned short height,
763 - if (!xW.initialised) return BadValue;
764 - return (*xW.XvMCClearSubpicture)(display, subpicture, x, y, width, height, color);
769 -XvMCCompositeSubpicture (
771 - XvMCSubpicture *subpicture,
775 - unsigned short width,
776 - unsigned short height,
781 - if (!xW.initialised) return BadValue;
782 - return (*xW.XvMCCompositeSubpicture)(display, subpicture, image, srcx, srcy,
783 - width, height, dstx, dsty);
787 -XvMCDestroySubpicture (Display *display, XvMCSubpicture *subpicture)
789 - if (!xW.initialised) return BadValue;
790 - return (*xW.XvMCDestroySubpicture)(display, subpicture);
794 -XvMCSetSubpicturePalette (
796 - XvMCSubpicture *subpicture,
797 - unsigned char *palette
800 - if (!xW.initialised) return BadValue;
801 - return (*xW.XvMCSetSubpicturePalette)(display, subpicture, palette);
806 -XvMCBlendSubpicture (
808 - XvMCSurface *target_surface,
809 - XvMCSubpicture *subpicture,
812 - unsigned short subw,
813 - unsigned short subh,
816 - unsigned short surfw,
817 - unsigned short surfh
820 - if (!xW.initialised) return BadValue;
821 - return (*xW.XvMCBlendSubpicture)(display, target_surface, subpicture,
822 - subx, suby, subw, subh, surfx, surfy,
827 -XvMCBlendSubpicture2 (
829 - XvMCSurface *source_surface,
830 - XvMCSurface *target_surface,
831 - XvMCSubpicture *subpicture,
834 - unsigned short subw,
835 - unsigned short subh,
838 - unsigned short surfw,
839 - unsigned short surfh
842 - if (!xW.initialised) return BadValue;
843 - return (*xW.XvMCBlendSubpicture2)(display, source_surface, target_surface, subpicture,
844 - subx, suby, subw, subh, surfx, surfy, surfw, surfh);
848 -Status XvMCSyncSurface (Display *display, XvMCSurface *surface)
850 - if (!xW.initialised) return BadValue;
851 - return (*xW.XvMCSyncSurface)(display, surface);
854 -Status XvMCFlushSurface (Display *display, XvMCSurface *surface)
856 - if (!xW.initialised) return BadValue;
857 - return (*xW.XvMCFlushSurface)(display, surface);
860 -Status XvMCGetSurfaceStatus (Display *display, XvMCSurface *surface, int *stat)
862 - if (!xW.initialised) return BadValue;
863 - return (*xW.XvMCGetSurfaceStatus)(display, surface, stat);
866 -Status XvMCRenderSurface (
868 - XvMCContext *context,
869 - unsigned int picture_structure,
870 - XvMCSurface *target_surface,
871 - XvMCSurface *past_surface,
872 - XvMCSurface *future_surface,
873 - unsigned int flags,
874 - unsigned int num_macroblocks,
875 - unsigned int first_macroblock,
876 - XvMCMacroBlockArray *macroblock_array,
877 - XvMCBlockArray *blocks
880 - if (!xW.initialised) return BadValue;
881 - return (*xW.XvMCRenderSurface)(display, context, picture_structure, target_surface,
882 - past_surface, future_surface, flags, num_macroblocks,
883 - first_macroblock, macroblock_array, blocks);
886 -Status XvMCSyncSubpicture (Display *display, XvMCSubpicture *subpicture)
888 - if (!xW.initialised) return BadValue;
889 - return (*xW.XvMCSyncSubpicture)(display, subpicture);
892 -Status XvMCFlushSubpicture (Display *display, XvMCSubpicture *subpicture)
894 - if (!xW.initialised) return BadValue;
895 - return (*xW.XvMCFlushSubpicture)(display, subpicture);
898 -XvMCGetSubpictureStatus (Display *display, XvMCSubpicture *subpic, int *stat)
900 - if (!xW.initialised) return BadValue;
901 - return (*xW.XvMCGetSubpictureStatus)(display, subpic, stat);
904 -Status XvMCCreateBlocks (
906 - XvMCContext *context,
907 - unsigned int num_blocks,
908 - XvMCBlockArray *block
911 - if (!xW.initialised) return BadValue;
912 - return (*xW.XvMCCreateBlocks)(display, context, num_blocks, block);
916 -Status XvMCDestroyBlocks (Display *display,XvMCBlockArray *block)
918 - if (!xW.initialised) return BadValue;
919 - return (*xW.XvMCDestroyBlocks)(display, block);
922 -Status XvMCCreateMacroBlocks (
924 - XvMCContext *context,
925 - unsigned int num_blocks,
926 - XvMCMacroBlockArray *blocks
929 - if (!xW.initialised) return BadValue;
930 - return (*xW.XvMCCreateMacroBlocks)(display, context, num_blocks, blocks);
934 -Status XvMCDestroyMacroBlocks (
936 - XvMCMacroBlockArray *block
939 - if (!xW.initialised) return BadValue;
940 - return (*xW.XvMCDestroyMacroBlocks)(display, block);
945 -XvMCQueryAttributes (
947 - XvMCContext *context,
951 - if (!xW.initialised) return NULL;
952 - return (*xW.XvMCQueryAttributes)(display, context, number);
959 - XvMCContext *context,
964 - if (!xW.initialised) return BadValue;
965 - return (*xW.XvMCSetAttribute)(display, context, attribute, value);
972 - XvMCContext *context,
977 - if (!xW.initialised) return BadValue;
978 - return (*xW.XvMCGetAttribute)(display, context, attribute, value);
982 -Status XvMCBeginSurface(Display *display,
983 - XvMCContext *context,
984 - XvMCSurface *target_surface,
985 - XvMCSurface *past_surface,
986 - XvMCSurface *future_surface,
987 - const XvMCMpegControl *control)
989 - if (!xW.vldextension) return BadValue;
990 - return (*xW.XvMCBeginSurface)(display, context, target_surface, past_surface, future_surface,
994 -Status XvMCLoadQMatrix(Display *display, XvMCContext *context,
995 - const XvMCQMatrix *qmx)
997 - if (!xW.vldextension) return BadValue;
998 - return (*xW.XvMCLoadQMatrix)(display, context, qmx);
1001 -Status XvMCPutSlice(Display *display,XvMCContext *context,
1002 - char *slice, int nBytes)
1004 - if (!xW.vldextension) return BadValue;
1005 - return (*xW.XvMCPutSlice)(display, context, slice, nBytes);
1008 -Status XvMCPutSlice2(Display *display,XvMCContext *context,
1009 - char *slice, int nBytes, int sliceCode)
1011 - if (!xW.vldextension) return BadValue;
1012 - return (*xW.XvMCPutSlice2)(display, context, slice, nBytes, sliceCode);
1014 diff --git a/wrapper/Makefile.am b/wrapper/Makefile.am
1015 new file mode 100644
1016 index 0000000..b3a1c21
1018 +++ b/wrapper/Makefile.am
1020 +lib_LTLIBRARIES = libXvMCW.la
1023 + -I$(top_srcdir)/include \
1024 + $(MALLOC_ZERO_CFLAGS) \
1025 + -DXVMC_CONFIGDIR=$(sysconfdir)/X11 \
1026 + -DXVMC_SOVERSION=\".1.0\" \
1027 + -DXV_SOVERSION=\".1.0\"
1029 +AM_CFLAGS = $(CWARNFLAGS) $(XVMC_CFLAGS)
1031 +libXvMCW_la_SOURCES = XvMCWrapper.c
1032 +libXvMCW_la_LIBADD = $(XVMC_LIBS)
1033 +libXvMCW_la_LDFLAGS = -version-number 1:0:0 -no-undefined
1036 +ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) \
1037 + $(AM_CPPFLAGS) $(CPPFLAGS)
1040 + $(LINT) $(ALL_LINT_FLAGS) $(libXvMCW_la_SOURCES) $(AM_CFLAGS) $(XVMC_LIBS)
1042 diff --git a/wrapper/XvMCWrapper.c b/wrapper/XvMCWrapper.c
1043 new file mode 100644
1044 index 0000000..bff5a8b
1046 +++ b/wrapper/XvMCWrapper.c
1048 +/*****************************************************************************
1049 + * XvMC Wrapper including the Nonstandard VLD extension.
1051 + * Copyright (c) 2004 The Unichrome project. All rights reserved.
1054 + * Permission is hereby granted, free of charge, to any person obtaining a
1055 + * copy of this software and associated documentation files (the "Software"),
1056 + * to deal in the Software without restriction, including without limitation
1057 + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1058 + * and/or sell copies of the Software, and to permit persons to whom the
1059 + * Software is furnished to do so, subject to the following conditions:
1061 + * The above copyright notice and this permission notice shall be included in
1062 + * all copies or substantial portions of the Software.
1064 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1065 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1066 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1067 + * AUTHOR(S) OR COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1068 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1069 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1070 + * DEALINGS IN THE SOFTWARE.
1072 + * Author: Thomas Hellström (2004)
1076 + * BUGS: The wrapper really should maintain one symbol table per port. This
1077 + * could possibly be impemented, To do that, the port-independent symbols need to be lifted out,
1078 + * and one would have to create a number of mapping tables:
1080 + * port -> symbol table
1083 + * subpicture -> port
1085 + * and reference the right table when needed.
1086 + * This needs to be done only if there is a player that wants to access two displays with different
1087 + * hardware simultaneously. Not likely as of today.
1090 +#ifdef HAVE_CONFIG_H
1091 + #include "config.h"
1094 +#include <X11/Xlib.h>
1095 +#include <X11/extensions/XvMC.h>
1096 +#include <X11/extensions/XvMClib.h>
1097 +#include <X11/extensions/vldXvMC.h>
1100 +#include <string.h>
1102 +#include <stdlib.h>
1105 +typedef Bool (*XvMCQueryExtensionP) (Display *, int *, int *);
1106 +typedef Status (*XvMCQueryVersionP) (Display *, int *,int *);
1107 +typedef XvMCSurfaceInfo * (*XvMCListSurfaceTypesP)(Display *, XvPortID, int *);
1108 +typedef Status (* XvMCCreateContextP) (Display *,XvPortID,int ,int ,int ,int ,XvMCContext * );
1109 +typedef Status (*XvMCDestroyContextP) (Display *, XvMCContext * );
1110 +typedef Status (*XvMCCreateSurfaceP)(Display *,XvMCContext *,XvMCSurface *);
1111 +typedef Status (*XvMCDestroySurfaceP)(Display *, XvMCSurface *);
1112 +typedef XvImageFormatValues * (*XvMCListSubpictureTypesP) (Display *,XvPortID ,int ,int *);
1113 +typedef Status (*XvMCPutSurfaceP)(Display *,XvMCSurface *,Drawable ,short , short , unsigned short ,
1114 + unsigned short ,short ,short ,unsigned short ,unsigned short ,int );
1115 +typedef Status (*XvMCHideSurfaceP)(Display *, XvMCSurface *);
1116 +typedef Status (*XvMCCreateSubpictureP) (Display *, XvMCContext *, XvMCSubpicture *,
1117 + unsigned short, unsigned short,int);
1118 +typedef Status (*XvMCClearSubpictureP) (Display *,XvMCSubpicture *,short,short,unsigned short,unsigned short,
1120 +typedef Status (*XvMCCompositeSubpictureP) (Display *, XvMCSubpicture *,XvImage *,short,short,
1121 + unsigned short, unsigned short,short,short);
1122 +typedef Status (*XvMCDestroySubpictureP) (Display *, XvMCSubpicture *);
1123 +typedef Status (*XvMCSetSubpicturePaletteP) (Display *, XvMCSubpicture *, unsigned char *);
1124 +typedef Status (*XvMCBlendSubpictureP) (Display *d,XvMCSurface *,XvMCSubpicture *,short,
1125 + short,unsigned short,unsigned short,short,short,
1126 + unsigned short,unsigned short);
1127 +typedef Status (*XvMCBlendSubpicture2P) (Display *,XvMCSurface *,XvMCSurface *,
1128 + XvMCSubpicture *,short,short,unsigned short,
1129 + unsigned short,short,short,unsigned short,
1131 +typedef Status (*XvMCSyncSurfaceP) (Display *, XvMCSurface *);
1132 +typedef Status (*XvMCFlushSurfaceP) (Display *, XvMCSurface *);
1133 +typedef Status (*XvMCGetSurfaceStatusP) (Display *, XvMCSurface *, int *);
1134 +typedef Status (*XvMCRenderSurfaceP) (Display *,XvMCContext *,unsigned int,XvMCSurface *,
1135 + XvMCSurface *,XvMCSurface *,unsigned int,unsigned int,
1136 + unsigned int,XvMCMacroBlockArray *,XvMCBlockArray *);
1137 +typedef Status (*XvMCSyncSubpictureP) (Display *, XvMCSubpicture *);
1138 +typedef Status (*XvMCFlushSubpictureP) (Display *, XvMCSubpicture *);
1139 +typedef Status (*XvMCGetSubpictureStatusP) (Display *, XvMCSubpicture *, int *);
1140 +typedef Status (*XvMCCreateBlocksP) (Display *, XvMCContext *,unsigned int,XvMCBlockArray *);
1141 +typedef Status (*XvMCDestroyBlocksP) (Display *,XvMCBlockArray *);
1142 +typedef Status (*XvMCCreateMacroBlocksP) (Display *,XvMCContext *,unsigned int,
1143 + XvMCMacroBlockArray *);
1144 +typedef Status (*XvMCDestroyMacroBlocksP) (Display *,XvMCMacroBlockArray *);
1145 +typedef XvAttribute *(*XvMCQueryAttributesP) (Display *,XvMCContext *,int *);
1146 +typedef Status (*XvMCSetAttributeP) (Display *,XvMCContext *, Atom, int);
1147 +typedef Status (*XvMCGetAttributeP) (Display *,XvMCContext *, Atom, int *);
1150 + * Nonstandard VLD acceleration level:
1153 +typedef Status (*XvMCBeginSurfaceP) (Display *,XvMCContext *,XvMCSurface *,
1154 + XvMCSurface *,XvMCSurface *f,const XvMCMpegControl *);
1155 +typedef Status (*XvMCLoadQMatrixP) (Display *, XvMCContext *,const XvMCQMatrix *);
1156 +typedef Status (*XvMCPutSliceP)(Display *,XvMCContext *, char *,int);
1157 +typedef Status (*XvMCPutSlice2P)(Display *,XvMCContext *, char *,int, unsigned);
1158 +typedef Status (*XvMCGetDRInfoP)(Display *, XvPortID, char **, char **, int *, int *,
1163 + XvMCQueryExtensionP XvMCQueryExtension;
1164 + XvMCQueryVersionP XvMCQueryVersion;
1165 + XvMCListSurfaceTypesP XvMCListSurfaceTypes;
1166 + XvMCCreateContextP XvMCCreateContext;
1167 + XvMCDestroyContextP XvMCDestroyContext;
1168 + XvMCCreateSurfaceP XvMCCreateSurface;
1169 + XvMCDestroySurfaceP XvMCDestroySurface;
1170 + XvMCListSubpictureTypesP XvMCListSubpictureTypes;
1171 + XvMCPutSurfaceP XvMCPutSurface;
1172 + XvMCHideSurfaceP XvMCHideSurface;
1173 + XvMCCreateSubpictureP XvMCCreateSubpicture;
1174 + XvMCClearSubpictureP XvMCClearSubpicture;
1175 + XvMCCompositeSubpictureP XvMCCompositeSubpicture;
1176 + XvMCDestroySubpictureP XvMCDestroySubpicture;
1177 + XvMCSetSubpicturePaletteP XvMCSetSubpicturePalette;
1178 + XvMCBlendSubpictureP XvMCBlendSubpicture;
1179 + XvMCBlendSubpicture2P XvMCBlendSubpicture2;
1180 + XvMCSyncSurfaceP XvMCSyncSurface;
1181 + XvMCFlushSurfaceP XvMCFlushSurface;
1182 + XvMCGetSurfaceStatusP XvMCGetSurfaceStatus;
1183 + XvMCRenderSurfaceP XvMCRenderSurface;
1184 + XvMCSyncSubpictureP XvMCSyncSubpicture;
1185 + XvMCFlushSubpictureP XvMCFlushSubpicture;
1186 + XvMCGetSubpictureStatusP XvMCGetSubpictureStatus;
1187 + XvMCCreateBlocksP XvMCCreateBlocks;
1188 + XvMCDestroyBlocksP XvMCDestroyBlocks;
1189 + XvMCCreateMacroBlocksP XvMCCreateMacroBlocks;
1190 + XvMCDestroyMacroBlocksP XvMCDestroyMacroBlocks;
1191 + XvMCQueryAttributesP XvMCQueryAttributes;
1192 + XvMCSetAttributeP XvMCSetAttribute;
1193 + XvMCGetAttributeP XvMCGetAttribute;
1196 + * Nonstandard VLD acceleration level:
1199 + XvMCBeginSurfaceP XvMCBeginSurface;
1200 + XvMCLoadQMatrixP XvMCLoadQMatrix;
1201 + XvMCPutSliceP XvMCPutSlice;
1202 + XvMCPutSlice2P XvMCPutSlice2;
1205 + * Driver name function.
1208 + XvMCGetDRInfoP XvMCGetDRInfo;
1210 + int preInitialised;
1215 +static XvMCWrapper xW;
1216 +static int wrapperInit = 0;
1217 +static int wrapperPreInit = 0;
1218 +static void *xvhandle;
1219 +static void *handle2;
1223 +#define STRS(ARG) STR(ARG)
1224 +#define STR(ARG) #ARG
1226 +#define XW_RSYM(base,handle,handle2,pointer, retval) \
1228 + register char *err; \
1229 + base.pointer = (pointer##P) dlsym((handle),#pointer); \
1230 + if ((err = dlerror()) != NULL) { \
1232 + fprintf(stderr,"%s\n",err); return retval; \
1234 + base.pointer = (pointer##P) dlsym((handle2),#pointer); \
1235 + if ((err = dlerror()) != NULL) { \
1236 + fprintf(stderr,"%s\n",err); return retval; \
1241 +#define XW_RSYM2(base,handle,handle2,pointer) \
1242 + base.pointer = (pointer##P) dlsym((handle),#pointer); \
1243 + if (dlerror() != NULL) { \
1244 + base.pointer = (pointer##P) dlsym((handle2),#pointer); \
1245 + if (dlerror() != NULL) return; \
1250 + * Try to dlopen a shared library, versionless first.
1254 +static void *dlopenversion(const char *lib, const char *version, int flag)
1257 + int curLen,verLen;
1262 + curLen = strlen(lib) + (verLen = strlen(version)) + 1;
1263 + curName = (char *) malloc(curLen * sizeof(char));
1264 + strncpy( curName, lib, curLen);
1266 + if (NULL != (tail = strstr(version+1,"."))) {
1267 + strncat( curName, version, tail - version);
1269 + strncat( curName, version, verLen);
1272 + ret = dlopen(curName, flag);
1277 +static int preInitW(Display *dpy)
1281 + * Resolve functions that are not hw driver specific.
1284 + void *handleZ = NULL;
1286 + wrapperPreInit = 1;
1287 + xW.preInitialised = 0;
1288 + xW.initialised = 0;
1289 + xvhandle = dlopenversion("libXv.so", XV_SOVERSION, RTLD_LAZY | RTLD_GLOBAL);
1291 + fprintf(stderr,"XvMCWrapper: Warning! Could not open shared "
1292 + "library \"libXv.so" XV_SOVERSION "\"\nThis may cause relocation "
1293 + "errors later.\nError was: \"%s\".\n",dlerror());
1295 + handle2 = dlopenversion("libXvMC.so", XVMC_SOVERSION, RTLD_LAZY | RTLD_GLOBAL);
1297 + fprintf(stderr,"XvMCWrapper: Could not load XvMC "
1298 + "library \"libXvMC.so" XVMC_SOVERSION "\". Failing\n");
1299 + fprintf(stderr,"%s\n",dlerror());
1302 + XW_RSYM(xW, handle2, handleZ, XvMCQueryExtension, 1);
1303 + XW_RSYM(xW, handle2, handleZ, XvMCQueryVersion, 1);
1304 + xW.preInitialised = 1;
1308 +static void initW(Display *dpy, XvPortID port)
1310 + char nameBuffer[BUFLEN];
1313 + char *clientName = NULL;
1317 + int major,minor,patchLevel,isLocal;
1318 + char *busID = NULL;
1321 + xW.initialised = 0;
1323 + if (!wrapperPreInit)
1324 + if (preInitW( dpy )) return;
1327 + * Will the DDX tell us the client driver name?
1330 + xW.XvMCGetDRInfo = (XvMCGetDRInfoP)
1331 + dlsym(handle2,"XvMCGetDRInfo");
1333 + if ((err = dlerror()) == NULL) {
1334 + if (0 == xW.XvMCGetDRInfo( dpy, port, &clientName, &busID, &major,
1335 + &minor,&patchLevel, &isLocal)) {
1336 + nameLen = strlen(clientName);
1339 + fprintf(stderr,"XvMCWrapper: X server is not local. Cannot run XvMC.\n");
1340 + XFree(clientName);
1344 + clientName = NULL;
1348 + if (clientName && (nameLen < BUFLEN-7) && (nameLen > 0)) {
1350 + strncpy(nameBuffer,"lib",BUFLEN-1);
1351 + strncpy(nameBuffer+3, clientName, BUFLEN-4);
1352 + strncpy(nameBuffer + nameLen, ".so", BUFLEN-nameLen-1);
1353 + nameBuffer[BUFLEN-1] = 0;
1354 + XFree(clientName);
1355 + handle = dlopenversion(nameBuffer, XVMC_SOVERSION,RTLD_LAZY);
1358 + * No. Try to obtain it from the config file.
1361 + if (clientName) XFree(clientName);
1363 + configFile = fopen(STRS(XVMC_CONFIGDIR) "/XvMCConfig","r");
1365 + xW.initialised = 0;
1366 + xW.vldextension = 0;
1368 + if (NULL == configFile) {
1369 + fprintf(stderr,"XvMCWrapper: Could not open config file \"%s\".\n",
1370 + STRS(XVMC_CONFIGDIR) "/XvMCConfig");
1371 + perror("XvMCWrapper");
1375 + if (NULL == fgets(nameBuffer, BUFLEN, configFile)) {
1376 + fclose(configFile);
1377 + fprintf(stderr,"XvMCWrapper: Could not read XvMC library name.\n");
1378 + perror("XvMCWrapper");
1382 + fclose(configFile);
1383 + if ((tmp = strlen(nameBuffer)) == 0) {
1384 + fprintf(stderr,"XvMCWrapper: Zero length XvMC library name.\n");
1385 + fprintf(stderr,"%s\n",dlerror());
1390 + * Skip trailing newlines and garbage.
1393 + while (iscntrl(nameBuffer[tmp-1])) {
1394 + nameBuffer[tmp-1] = 0;
1396 + fprintf(stderr,"XvMCWrapper: Zero length XvMC library name.\n");
1400 + handle = dlopen(nameBuffer,RTLD_LAZY);
1403 + fprintf(stderr,"XvMCWrapper: Could not load hardware specific XvMC "
1404 + "library \"%s\".\n",nameBuffer);
1405 + fprintf(stderr,"%s\n",dlerror());
1409 + XW_RSYM(xW, handle, handle2, XvMCListSurfaceTypes,);
1410 + XW_RSYM(xW, handle, handle2, XvMCCreateContext,);
1411 + XW_RSYM(xW, handle, handle2, XvMCDestroyContext,);
1412 + XW_RSYM(xW, handle, handle2, XvMCCreateSurface,);
1413 + XW_RSYM(xW, handle, handle2, XvMCDestroySurface,);
1414 + XW_RSYM(xW, handle, handle2, XvMCListSubpictureTypes,);
1415 + XW_RSYM(xW, handle, handle2, XvMCHideSurface,);
1416 + XW_RSYM(xW, handle, handle2, XvMCCreateSubpicture,);
1417 + XW_RSYM(xW, handle, handle2, XvMCClearSubpicture,);
1418 + XW_RSYM(xW, handle, handle2, XvMCCompositeSubpicture,);
1419 + XW_RSYM(xW, handle, handle2, XvMCDestroySubpicture,);
1420 + XW_RSYM(xW, handle, handle2, XvMCSetSubpicturePalette,);
1421 + XW_RSYM(xW, handle, handle2, XvMCBlendSubpicture,);
1422 + XW_RSYM(xW, handle, handle2, XvMCBlendSubpicture2,);
1423 + XW_RSYM(xW, handle, handle2, XvMCPutSurface,);
1424 + XW_RSYM(xW, handle, handle2, XvMCSyncSurface,);
1425 + XW_RSYM(xW, handle, handle2, XvMCFlushSurface,);
1426 + XW_RSYM(xW, handle, handle2, XvMCGetSurfaceStatus,);
1427 + XW_RSYM(xW, handle, handle2, XvMCRenderSurface,);
1428 + XW_RSYM(xW, handle, handle2, XvMCSyncSubpicture,);
1429 + XW_RSYM(xW, handle, handle2, XvMCFlushSubpicture,);
1430 + XW_RSYM(xW, handle, handle2, XvMCGetSubpictureStatus,);
1431 + XW_RSYM(xW, handle, handle2, XvMCCreateBlocks,);
1432 + XW_RSYM(xW, handle, handle2, XvMCDestroyBlocks,);
1433 + XW_RSYM(xW, handle, handle2, XvMCCreateMacroBlocks,);
1434 + XW_RSYM(xW, handle, handle2, XvMCDestroyMacroBlocks,);
1435 + XW_RSYM(xW, handle, handle2, XvMCQueryAttributes,);
1436 + XW_RSYM(xW, handle, handle2, XvMCSetAttribute,);
1437 + XW_RSYM(xW, handle, handle2, XvMCGetAttribute,);
1438 + xW.initialised = 1;
1439 + XW_RSYM2(xW, handle, handle2, XvMCBeginSurface);
1440 + XW_RSYM(xW, handle, handle2, XvMCLoadQMatrix,);
1441 + XW_RSYM(xW, handle, handle2, XvMCPutSlice,);
1442 + XW_RSYM(xW, handle, handle2, XvMCPutSlice2,);
1443 + xW.vldextension = 1;
1447 +Bool XvMCQueryExtension (Display *display, int *eventBase, int *errBase)
1449 + if (!wrapperPreInit) preInitW( display );
1450 + if (!xW.preInitialised) return 0;
1451 + return (*xW.XvMCQueryExtension)(display, eventBase, errBase);
1454 +Status XvMCQueryVersion (Display *display, int *major_versionp,
1455 + int *minor_versionp)
1457 + if (!wrapperPreInit) preInitW( display );
1458 + if (!xW.preInitialised) return 0;
1459 + return (*xW.XvMCQueryVersion)(display, major_versionp, minor_versionp);
1463 +XvMCSurfaceInfo * XvMCListSurfaceTypes(Display *dpy, XvPortID port, int *num)
1465 + if (!wrapperInit) initW( dpy, port);
1466 + if (!xW.initialised) return NULL;
1467 + return (*xW.XvMCListSurfaceTypes)(dpy, port, num);
1470 +Status XvMCCreateContext (
1473 + int surface_type_id,
1477 + XvMCContext * context
1480 + if (!wrapperInit) initW(display, port);
1481 + if (!xW.initialised) return BadValue;
1482 + return (*xW.XvMCCreateContext)(display, port, surface_type_id,
1483 + width, height, flags, context);
1486 +Status XvMCDestroyContext (Display *display, XvMCContext * context)
1488 + if (!xW.initialised) return BadValue;
1489 + return (*xW.XvMCDestroyContext)(display, context);
1495 + XvMCContext * context,
1496 + XvMCSurface * surface
1499 + if (!xW.initialised) return BadValue;
1500 + return (*xW.XvMCCreateSurface)(display, context, surface);
1503 +Status XvMCDestroySurface(Display *display, XvMCSurface *surface)
1505 + if (!xW.initialised) return BadValue;
1506 + return (*xW.XvMCDestroySurface)(display, surface);
1510 +XvImageFormatValues * XvMCListSubpictureTypes (
1511 + Display * display,
1513 + int surface_type_id,
1517 + if (!xW.initialised) return NULL;
1518 + return (*xW.XvMCListSubpictureTypes)(display, port, surface_type_id,
1526 + XvMCSurface *surface,
1530 + unsigned short srcw,
1531 + unsigned short srch,
1534 + unsigned short destw,
1535 + unsigned short desth,
1539 + if (!xW.initialised) return BadValue;
1540 + return (*xW.XvMCPutSurface)(display, surface, draw, srcx, srcy, srcw, srch,
1541 + destx, desty, destw, desth, flags);
1544 +Status XvMCHideSurface(Display *display, XvMCSurface *surface)
1546 + if (!xW.initialised) return BadValue;
1547 + return (*xW.XvMCHideSurface)(display, surface);
1552 +XvMCCreateSubpicture (
1554 + XvMCContext *context,
1555 + XvMCSubpicture *subpicture,
1556 + unsigned short width,
1557 + unsigned short height,
1561 + if (!xW.initialised) return BadValue;
1562 + return (*xW.XvMCCreateSubpicture)(display, context, subpicture, width, height,
1568 +XvMCClearSubpicture (
1570 + XvMCSubpicture *subpicture,
1573 + unsigned short width,
1574 + unsigned short height,
1575 + unsigned int color
1578 + if (!xW.initialised) return BadValue;
1579 + return (*xW.XvMCClearSubpicture)(display, subpicture, x, y, width, height, color);
1584 +XvMCCompositeSubpicture (
1586 + XvMCSubpicture *subpicture,
1590 + unsigned short width,
1591 + unsigned short height,
1596 + if (!xW.initialised) return BadValue;
1597 + return (*xW.XvMCCompositeSubpicture)(display, subpicture, image, srcx, srcy,
1598 + width, height, dstx, dsty);
1602 +XvMCDestroySubpicture (Display *display, XvMCSubpicture *subpicture)
1604 + if (!xW.initialised) return BadValue;
1605 + return (*xW.XvMCDestroySubpicture)(display, subpicture);
1609 +XvMCSetSubpicturePalette (
1611 + XvMCSubpicture *subpicture,
1612 + unsigned char *palette
1615 + if (!xW.initialised) return BadValue;
1616 + return (*xW.XvMCSetSubpicturePalette)(display, subpicture, palette);
1621 +XvMCBlendSubpicture (
1623 + XvMCSurface *target_surface,
1624 + XvMCSubpicture *subpicture,
1627 + unsigned short subw,
1628 + unsigned short subh,
1631 + unsigned short surfw,
1632 + unsigned short surfh
1635 + if (!xW.initialised) return BadValue;
1636 + return (*xW.XvMCBlendSubpicture)(display, target_surface, subpicture,
1637 + subx, suby, subw, subh, surfx, surfy,
1642 +XvMCBlendSubpicture2 (
1644 + XvMCSurface *source_surface,
1645 + XvMCSurface *target_surface,
1646 + XvMCSubpicture *subpicture,
1649 + unsigned short subw,
1650 + unsigned short subh,
1653 + unsigned short surfw,
1654 + unsigned short surfh
1657 + if (!xW.initialised) return BadValue;
1658 + return (*xW.XvMCBlendSubpicture2)(display, source_surface, target_surface, subpicture,
1659 + subx, suby, subw, subh, surfx, surfy, surfw, surfh);
1663 +Status XvMCSyncSurface (Display *display, XvMCSurface *surface)
1665 + if (!xW.initialised) return BadValue;
1666 + return (*xW.XvMCSyncSurface)(display, surface);
1669 +Status XvMCFlushSurface (Display *display, XvMCSurface *surface)
1671 + if (!xW.initialised) return BadValue;
1672 + return (*xW.XvMCFlushSurface)(display, surface);
1675 +Status XvMCGetSurfaceStatus (Display *display, XvMCSurface *surface, int *stat)
1677 + if (!xW.initialised) return BadValue;
1678 + return (*xW.XvMCGetSurfaceStatus)(display, surface, stat);
1681 +Status XvMCRenderSurface (
1683 + XvMCContext *context,
1684 + unsigned int picture_structure,
1685 + XvMCSurface *target_surface,
1686 + XvMCSurface *past_surface,
1687 + XvMCSurface *future_surface,
1688 + unsigned int flags,
1689 + unsigned int num_macroblocks,
1690 + unsigned int first_macroblock,
1691 + XvMCMacroBlockArray *macroblock_array,
1692 + XvMCBlockArray *blocks
1695 + if (!xW.initialised) return BadValue;
1696 + return (*xW.XvMCRenderSurface)(display, context, picture_structure, target_surface,
1697 + past_surface, future_surface, flags, num_macroblocks,
1698 + first_macroblock, macroblock_array, blocks);
1701 +Status XvMCSyncSubpicture (Display *display, XvMCSubpicture *subpicture)
1703 + if (!xW.initialised) return BadValue;
1704 + return (*xW.XvMCSyncSubpicture)(display, subpicture);
1707 +Status XvMCFlushSubpicture (Display *display, XvMCSubpicture *subpicture)
1709 + if (!xW.initialised) return BadValue;
1710 + return (*xW.XvMCFlushSubpicture)(display, subpicture);
1713 +XvMCGetSubpictureStatus (Display *display, XvMCSubpicture *subpic, int *stat)
1715 + if (!xW.initialised) return BadValue;
1716 + return (*xW.XvMCGetSubpictureStatus)(display, subpic, stat);
1719 +Status XvMCCreateBlocks (
1721 + XvMCContext *context,
1722 + unsigned int num_blocks,
1723 + XvMCBlockArray *block
1726 + if (!xW.initialised) return BadValue;
1727 + return (*xW.XvMCCreateBlocks)(display, context, num_blocks, block);
1731 +Status XvMCDestroyBlocks (Display *display,XvMCBlockArray *block)
1733 + if (!xW.initialised) return BadValue;
1734 + return (*xW.XvMCDestroyBlocks)(display, block);
1737 +Status XvMCCreateMacroBlocks (
1739 + XvMCContext *context,
1740 + unsigned int num_blocks,
1741 + XvMCMacroBlockArray *blocks
1744 + if (!xW.initialised) return BadValue;
1745 + return (*xW.XvMCCreateMacroBlocks)(display, context, num_blocks, blocks);
1749 +Status XvMCDestroyMacroBlocks (
1751 + XvMCMacroBlockArray *block
1754 + if (!xW.initialised) return BadValue;
1755 + return (*xW.XvMCDestroyMacroBlocks)(display, block);
1760 +XvMCQueryAttributes (
1762 + XvMCContext *context,
1766 + if (!xW.initialised) return NULL;
1767 + return (*xW.XvMCQueryAttributes)(display, context, number);
1774 + XvMCContext *context,
1779 + if (!xW.initialised) return BadValue;
1780 + return (*xW.XvMCSetAttribute)(display, context, attribute, value);
1787 + XvMCContext *context,
1792 + if (!xW.initialised) return BadValue;
1793 + return (*xW.XvMCGetAttribute)(display, context, attribute, value);
1797 +Status XvMCBeginSurface(Display *display,
1798 + XvMCContext *context,
1799 + XvMCSurface *target_surface,
1800 + XvMCSurface *past_surface,
1801 + XvMCSurface *future_surface,
1802 + const XvMCMpegControl *control)
1804 + if (!xW.vldextension) return BadValue;
1805 + return (*xW.XvMCBeginSurface)(display, context, target_surface, past_surface, future_surface,
1809 +Status XvMCLoadQMatrix(Display *display, XvMCContext *context,
1810 + const XvMCQMatrix *qmx)
1812 + if (!xW.vldextension) return BadValue;
1813 + return (*xW.XvMCLoadQMatrix)(display, context, qmx);
1816 +Status XvMCPutSlice(Display *display,XvMCContext *context,
1817 + char *slice, int nBytes)
1819 + if (!xW.vldextension) return BadValue;
1820 + return (*xW.XvMCPutSlice)(display, context, slice, nBytes);
1823 +Status XvMCPutSlice2(Display *display,XvMCContext *context,
1824 + char *slice, int nBytes, int sliceCode)
1826 + if (!xW.vldextension) return BadValue;
1827 + return (*xW.XvMCPutSlice2)(display, context, slice, nBytes, sliceCode);