| 1 |
/***************************************************************************** |
| 2 |
* XvMC Wrapper including the Nonstandard VLD extension. |
| 3 |
* |
| 4 |
* Copyright (c) 2004 The Unichrome project. All rights reserved. |
| 5 |
* |
| 6 |
* |
| 7 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 8 |
* copy of this software and associated documentation files (the "Software"), |
| 9 |
* to deal in the Software without restriction, including without limitation |
| 10 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 12 |
* Software is furnished to do so, subject to the following conditions: |
| 13 |
* |
| 14 |
* The above copyright notice and this permission notice shall be included in |
| 15 |
* all copies or substantial portions of the Software. |
| 16 |
* |
| 17 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 |
* AUTHOR(S) OR COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 23 |
* DEALINGS IN THE SOFTWARE. |
| 24 |
* |
| 25 |
* Author: Thomas Hellström (2004) |
| 26 |
*/ |
| 27 |
|
| 28 |
/* |
| 29 |
* BUGS: The wrapper really should maintain one symbol table per port. This |
| 30 |
* could possibly be impemented, To do that, the port-independent symbols need to be lifted out, |
| 31 |
* and one would have to create a number of mapping tables: |
| 32 |
* |
| 33 |
* port -> symbol table |
| 34 |
* context -> port |
| 35 |
* surface -> port |
| 36 |
* subpicture -> port |
| 37 |
* |
| 38 |
* and reference the right table when needed. |
| 39 |
* This needs to be done only if there is a player that wants to access two displays with different |
| 40 |
* hardware simultaneously. Not likely as of today. |
| 41 |
*/ |
| 42 |
|
| 43 |
#ifdef HAVE_CONFIG_H |
| 44 |
#include "config.h" |
| 45 |
#endif |
| 46 |
|
| 47 |
#include <X11/Xlib.h> |
| 48 |
#include <X11/extensions/XvMC.h> |
| 49 |
#include <X11/extensions/XvMClib.h> |
| 50 |
#include "X11/extensions/vldXvMC.h" |
| 51 |
#include <dlfcn.h> |
| 52 |
#include <stdio.h> |
| 53 |
#include <string.h> |
| 54 |
#include <ctype.h> |
| 55 |
#include <stdlib.h> |
| 56 |
|
| 57 |
|
| 58 |
typedef Bool (*XvMCQueryExtensionP) (Display *, int *, int *); |
| 59 |
typedef Status (*XvMCQueryVersionP) (Display *, int *,int *); |
| 60 |
typedef XvMCSurfaceInfo * (*XvMCListSurfaceTypesP)(Display *, XvPortID, int *); |
| 61 |
typedef Status (* XvMCCreateContextP) (Display *,XvPortID,int ,int ,int ,int ,XvMCContext * ); |
| 62 |
typedef Status (*XvMCDestroyContextP) (Display *, XvMCContext * ); |
| 63 |
typedef Status (*XvMCCreateSurfaceP)(Display *,XvMCContext *,XvMCSurface *); |
| 64 |
typedef Status (*XvMCDestroySurfaceP)(Display *, XvMCSurface *); |
| 65 |
typedef XvImageFormatValues * (*XvMCListSubpictureTypesP) (Display *,XvPortID ,int ,int *); |
| 66 |
typedef Status (*XvMCPutSurfaceP)(Display *,XvMCSurface *,Drawable ,short , short , unsigned short , |
| 67 |
unsigned short ,short ,short ,unsigned short ,unsigned short ,int ); |
| 68 |
typedef Status (*XvMCHideSurfaceP)(Display *, XvMCSurface *); |
| 69 |
typedef Status (*XvMCCreateSubpictureP) (Display *, XvMCContext *, XvMCSubpicture *, |
| 70 |
unsigned short, unsigned short,int); |
| 71 |
typedef Status (*XvMCClearSubpictureP) (Display *,XvMCSubpicture *,short,short,unsigned short,unsigned short, |
| 72 |
unsigned int); |
| 73 |
typedef Status (*XvMCCompositeSubpictureP) (Display *, XvMCSubpicture *,XvImage *,short,short, |
| 74 |
unsigned short, unsigned short,short,short); |
| 75 |
typedef Status (*XvMCDestroySubpictureP) (Display *, XvMCSubpicture *); |
| 76 |
typedef Status (*XvMCSetSubpicturePaletteP) (Display *, XvMCSubpicture *, unsigned char *); |
| 77 |
typedef Status (*XvMCBlendSubpictureP) (Display *d,XvMCSurface *,XvMCSubpicture *,short, |
| 78 |
short,unsigned short,unsigned short,short,short, |
| 79 |
unsigned short,unsigned short); |
| 80 |
typedef Status (*XvMCBlendSubpicture2P) (Display *,XvMCSurface *,XvMCSurface *, |
| 81 |
XvMCSubpicture *,short,short,unsigned short, |
| 82 |
unsigned short,short,short,unsigned short, |
| 83 |
unsigned short); |
| 84 |
typedef Status (*XvMCSyncSurfaceP) (Display *, XvMCSurface *); |
| 85 |
typedef Status (*XvMCFlushSurfaceP) (Display *, XvMCSurface *); |
| 86 |
typedef Status (*XvMCGetSurfaceStatusP) (Display *, XvMCSurface *, int *); |
| 87 |
typedef Status (*XvMCRenderSurfaceP) (Display *,XvMCContext *,unsigned int,XvMCSurface *, |
| 88 |
XvMCSurface *,XvMCSurface *,unsigned int,unsigned int, |
| 89 |
unsigned int,XvMCMacroBlockArray *,XvMCBlockArray *); |
| 90 |
typedef Status (*XvMCSyncSubpictureP) (Display *, XvMCSubpicture *); |
| 91 |
typedef Status (*XvMCFlushSubpictureP) (Display *, XvMCSubpicture *); |
| 92 |
typedef Status (*XvMCGetSubpictureStatusP) (Display *, XvMCSubpicture *, int *); |
| 93 |
typedef Status (*XvMCCreateBlocksP) (Display *, XvMCContext *,unsigned int,XvMCBlockArray *); |
| 94 |
typedef Status (*XvMCDestroyBlocksP) (Display *,XvMCBlockArray *); |
| 95 |
typedef Status (*XvMCCreateMacroBlocksP) (Display *,XvMCContext *,unsigned int, |
| 96 |
XvMCMacroBlockArray *); |
| 97 |
typedef Status (*XvMCDestroyMacroBlocksP) (Display *,XvMCMacroBlockArray *); |
| 98 |
typedef XvAttribute *(*XvMCQueryAttributesP) (Display *,XvMCContext *,int *); |
| 99 |
typedef Status (*XvMCSetAttributeP) (Display *,XvMCContext *, Atom, int); |
| 100 |
typedef Status (*XvMCGetAttributeP) (Display *,XvMCContext *, Atom, int *); |
| 101 |
|
| 102 |
/* |
| 103 |
* Nonstandard VLD acceleration level: |
| 104 |
*/ |
| 105 |
|
| 106 |
typedef Status (*XvMCBeginSurfaceP) (Display *,XvMCContext *,XvMCSurface *, |
| 107 |
XvMCSurface *,XvMCSurface *f,const XvMCMpegControl *); |
| 108 |
typedef Status (*XvMCLoadQMatrixP) (Display *, XvMCContext *,const XvMCQMatrix *); |
| 109 |
typedef Status (*XvMCPutSliceP)(Display *,XvMCContext *, char *,int); |
| 110 |
typedef Status (*XvMCPutSlice2P)(Display *,XvMCContext *, char *,int, unsigned); |
| 111 |
typedef Status (*XvMCGetDRInfoP)(Display *, XvPortID, char **, char **, int *, int *, |
| 112 |
int *, int *); |
| 113 |
|
| 114 |
|
| 115 |
typedef struct { |
| 116 |
XvMCQueryExtensionP XvMCQueryExtension; |
| 117 |
XvMCQueryVersionP XvMCQueryVersion; |
| 118 |
XvMCListSurfaceTypesP XvMCListSurfaceTypes; |
| 119 |
XvMCCreateContextP XvMCCreateContext; |
| 120 |
XvMCDestroyContextP XvMCDestroyContext; |
| 121 |
XvMCCreateSurfaceP XvMCCreateSurface; |
| 122 |
XvMCDestroySurfaceP XvMCDestroySurface; |
| 123 |
XvMCListSubpictureTypesP XvMCListSubpictureTypes; |
| 124 |
XvMCPutSurfaceP XvMCPutSurface; |
| 125 |
XvMCHideSurfaceP XvMCHideSurface; |
| 126 |
XvMCCreateSubpictureP XvMCCreateSubpicture; |
| 127 |
XvMCClearSubpictureP XvMCClearSubpicture; |
| 128 |
XvMCCompositeSubpictureP XvMCCompositeSubpicture; |
| 129 |
XvMCDestroySubpictureP XvMCDestroySubpicture; |
| 130 |
XvMCSetSubpicturePaletteP XvMCSetSubpicturePalette; |
| 131 |
XvMCBlendSubpictureP XvMCBlendSubpicture; |
| 132 |
XvMCBlendSubpicture2P XvMCBlendSubpicture2; |
| 133 |
XvMCSyncSurfaceP XvMCSyncSurface; |
| 134 |
XvMCFlushSurfaceP XvMCFlushSurface; |
| 135 |
XvMCGetSurfaceStatusP XvMCGetSurfaceStatus; |
| 136 |
XvMCRenderSurfaceP XvMCRenderSurface; |
| 137 |
XvMCSyncSubpictureP XvMCSyncSubpicture; |
| 138 |
XvMCFlushSubpictureP XvMCFlushSubpicture; |
| 139 |
XvMCGetSubpictureStatusP XvMCGetSubpictureStatus; |
| 140 |
XvMCCreateBlocksP XvMCCreateBlocks; |
| 141 |
XvMCDestroyBlocksP XvMCDestroyBlocks; |
| 142 |
XvMCCreateMacroBlocksP XvMCCreateMacroBlocks; |
| 143 |
XvMCDestroyMacroBlocksP XvMCDestroyMacroBlocks; |
| 144 |
XvMCQueryAttributesP XvMCQueryAttributes; |
| 145 |
XvMCSetAttributeP XvMCSetAttribute; |
| 146 |
XvMCGetAttributeP XvMCGetAttribute; |
| 147 |
|
| 148 |
/* |
| 149 |
* Nonstandard VLD acceleration level: |
| 150 |
*/ |
| 151 |
|
| 152 |
XvMCBeginSurfaceP XvMCBeginSurface; |
| 153 |
XvMCLoadQMatrixP XvMCLoadQMatrix; |
| 154 |
XvMCPutSliceP XvMCPutSlice; |
| 155 |
XvMCPutSlice2P XvMCPutSlice2; |
| 156 |
|
| 157 |
/* |
| 158 |
* Driver name function. |
| 159 |
*/ |
| 160 |
|
| 161 |
XvMCGetDRInfoP XvMCGetDRInfo; |
| 162 |
|
| 163 |
int preInitialised; |
| 164 |
int initialised; |
| 165 |
int vldextension; |
| 166 |
} XvMCWrapper; |
| 167 |
|
| 168 |
static XvMCWrapper xW; |
| 169 |
static int wrapperInit = 0; |
| 170 |
static int wrapperPreInit = 0; |
| 171 |
static void *xvhandle; |
| 172 |
static void *handle2; |
| 173 |
|
| 174 |
#define BUFLEN 200 |
| 175 |
|
| 176 |
#define STRS(ARG) STR(ARG) |
| 177 |
#define STR(ARG) #ARG |
| 178 |
|
| 179 |
#define XW_RSYM(base,handle,handle2,pointer, retval) \ |
| 180 |
do { \ |
| 181 |
register char *symerr; \ |
| 182 |
base.pointer = (pointer##P) dlsym((handle),#pointer); \ |
| 183 |
if ((symerr = dlerror()) != NULL) { \ |
| 184 |
if (!handle2) { \ |
| 185 |
fprintf(stderr,"%s\n",symerr); return retval; \ |
| 186 |
} \ |
| 187 |
base.pointer = (pointer##P) dlsym((handle2),#pointer); \ |
| 188 |
if ((symerr = dlerror()) != NULL) { \ |
| 189 |
fprintf(stderr,"%s\n",symerr); return retval; \ |
| 190 |
} \ |
| 191 |
} \ |
| 192 |
} while (0); |
| 193 |
|
| 194 |
#define XW_RSYM2(base,handle,handle2,pointer) \ |
| 195 |
base.pointer = (pointer##P) dlsym((handle),#pointer); \ |
| 196 |
if (dlerror() != NULL) { \ |
| 197 |
base.pointer = (pointer##P) dlsym((handle2),#pointer); \ |
| 198 |
if (dlerror() != NULL) return; \ |
| 199 |
} |
| 200 |
|
| 201 |
|
| 202 |
/* |
| 203 |
* Try to dlopen a shared library, versionless first. |
| 204 |
*/ |
| 205 |
|
| 206 |
|
| 207 |
static void *dlopenversion(const char *lib, const char *version, int flag) |
| 208 |
{ |
| 209 |
void *ret; |
| 210 |
int curLen,verLen; |
| 211 |
char *curName; |
| 212 |
const char *tail; |
| 213 |
|
| 214 |
|
| 215 |
curLen = strlen(lib) + (verLen = strlen(version)) + 1; |
| 216 |
curName = (char *) malloc(curLen * sizeof(char)); |
| 217 |
strncpy( curName, lib, curLen); |
| 218 |
if (verLen > 1) { |
| 219 |
if (NULL != (tail = strstr(version+1,"."))) { |
| 220 |
strncat( curName, version, tail - version); |
| 221 |
} else { |
| 222 |
strncat( curName, version, verLen); |
| 223 |
} |
| 224 |
} |
| 225 |
ret = dlopen(curName, flag); |
| 226 |
free(curName); |
| 227 |
return ret; |
| 228 |
} |
| 229 |
|
| 230 |
static int preInitW(Display *dpy) |
| 231 |
{ |
| 232 |
|
| 233 |
/* |
| 234 |
* Resolve functions that are not hw driver specific. |
| 235 |
*/ |
| 236 |
|
| 237 |
void *handleZ = NULL; |
| 238 |
|
| 239 |
wrapperPreInit = 1; |
| 240 |
xW.preInitialised = 0; |
| 241 |
xW.initialised = 0; |
| 242 |
xvhandle = dlopenversion("libXv.so", XV_SOVERSION, RTLD_LAZY | RTLD_GLOBAL); |
| 243 |
if (!xvhandle) { |
| 244 |
fprintf(stderr,"XvMCWrapper: Warning! Could not open shared " |
| 245 |
"library \"libXv.so" XV_SOVERSION "\"\nThis may cause relocation " |
| 246 |
"errors later.\nError was: \"%s\".\n",dlerror()); |
| 247 |
} |
| 248 |
handle2 = dlopenversion("libXvMC.so", XVMC_SOVERSION, RTLD_LAZY | RTLD_GLOBAL); |
| 249 |
if (!handle2) { |
| 250 |
fprintf(stderr,"XvMCWrapper: Could not load XvMC " |
| 251 |
"library \"libXvMC.so" XVMC_SOVERSION "\". Failing\n"); |
| 252 |
fprintf(stderr,"%s\n",dlerror()); |
| 253 |
return 1; |
| 254 |
} |
| 255 |
XW_RSYM(xW, handle2, handleZ, XvMCQueryExtension, 1); |
| 256 |
XW_RSYM(xW, handle2, handleZ, XvMCQueryVersion, 1); |
| 257 |
xW.preInitialised = 1; |
| 258 |
return 0; |
| 259 |
} |
| 260 |
|
| 261 |
static void initW(Display *dpy, XvPortID port) |
| 262 |
{ |
| 263 |
char nameBuffer[BUFLEN]; |
| 264 |
void *handle; |
| 265 |
int tmp; |
| 266 |
char *clientName = NULL; |
| 267 |
char *err; |
| 268 |
FILE *configFile; |
| 269 |
int nameLen = 0; |
| 270 |
int major,minor,patchLevel,isLocal; |
| 271 |
char *busID = NULL; |
| 272 |
|
| 273 |
wrapperInit = 1; |
| 274 |
xW.initialised = 0; |
| 275 |
|
| 276 |
if (!wrapperPreInit) |
| 277 |
if (preInitW( dpy )) return; |
| 278 |
|
| 279 |
/* |
| 280 |
* Will the DDX tell us the client driver name? |
| 281 |
*/ |
| 282 |
|
| 283 |
xW.XvMCGetDRInfo = (XvMCGetDRInfoP) |
| 284 |
dlsym(handle2,"XvMCGetDRInfo"); |
| 285 |
|
| 286 |
if ((err = dlerror()) == NULL) { |
| 287 |
if (0 == xW.XvMCGetDRInfo( dpy, port, &clientName, &busID, &major, |
| 288 |
&minor,&patchLevel, &isLocal)) { |
| 289 |
nameLen = strlen(clientName); |
| 290 |
XFree(busID); |
| 291 |
if (!isLocal) { |
| 292 |
fprintf(stderr,"XvMCWrapper: X server is not local. Cannot run XvMC.\n"); |
| 293 |
XFree(clientName); |
| 294 |
return; |
| 295 |
} |
| 296 |
} else { |
| 297 |
clientName = NULL; |
| 298 |
} |
| 299 |
} |
| 300 |
|
| 301 |
if (clientName && (nameLen < BUFLEN-7) && (nameLen > 0)) { |
| 302 |
nameLen += 3; |
| 303 |
strncpy(nameBuffer,"lib",BUFLEN-1); |
| 304 |
strncpy(nameBuffer+3, clientName, BUFLEN-4); |
| 305 |
strncpy(nameBuffer + nameLen, ".so", BUFLEN-nameLen-1); |
| 306 |
nameBuffer[BUFLEN-1] = 0; |
| 307 |
XFree(clientName); |
| 308 |
handle = dlopenversion(nameBuffer, XVMC_SOVERSION,RTLD_LAZY); |
| 309 |
} else { |
| 310 |
/* |
| 311 |
* No. Try to obtain it from the config file. |
| 312 |
*/ |
| 313 |
|
| 314 |
if (clientName) XFree(clientName); |
| 315 |
|
| 316 |
configFile = fopen(STRS(XVMC_CONFIGDIR) "/XvMCConfig","r"); |
| 317 |
|
| 318 |
xW.initialised = 0; |
| 319 |
xW.vldextension = 0; |
| 320 |
|
| 321 |
if (NULL == configFile) { |
| 322 |
fprintf(stderr,"XvMCWrapper: Could not open config file \"%s\".\n", |
| 323 |
STRS(XVMC_CONFIGDIR) "/XvMCConfig"); |
| 324 |
perror("XvMCWrapper"); |
| 325 |
return; |
| 326 |
} |
| 327 |
|
| 328 |
if (NULL == fgets(nameBuffer, BUFLEN, configFile)) { |
| 329 |
fclose(configFile); |
| 330 |
fprintf(stderr,"XvMCWrapper: Could not read XvMC library name.\n"); |
| 331 |
perror("XvMCWrapper"); |
| 332 |
return; |
| 333 |
} |
| 334 |
|
| 335 |
fclose(configFile); |
| 336 |
if ((tmp = strlen(nameBuffer)) == 0) { |
| 337 |
fprintf(stderr,"XvMCWrapper: Zero length XvMC library name.\n"); |
| 338 |
fprintf(stderr,"%s\n",dlerror()); |
| 339 |
return; |
| 340 |
} |
| 341 |
|
| 342 |
/* |
| 343 |
* Skip trailing newlines and garbage. |
| 344 |
*/ |
| 345 |
|
| 346 |
while (iscntrl(nameBuffer[tmp-1])) { |
| 347 |
nameBuffer[tmp-1] = 0; |
| 348 |
if (--tmp == 0) { |
| 349 |
fprintf(stderr,"XvMCWrapper: Zero length XvMC library name.\n"); |
| 350 |
return; |
| 351 |
} |
| 352 |
} |
| 353 |
handle = dlopen(nameBuffer,RTLD_LAZY); |
| 354 |
} |
| 355 |
if (!handle) { |
| 356 |
fprintf(stderr,"XvMCWrapper: Could not load hardware specific XvMC " |
| 357 |
"library \"%s\".\n",nameBuffer); |
| 358 |
fprintf(stderr,"%s\n",dlerror()); |
| 359 |
return; |
| 360 |
} |
| 361 |
|
| 362 |
XW_RSYM(xW, handle, handle2, XvMCListSurfaceTypes,); |
| 363 |
XW_RSYM(xW, handle, handle2, XvMCCreateContext,); |
| 364 |
XW_RSYM(xW, handle, handle2, XvMCDestroyContext,); |
| 365 |
XW_RSYM(xW, handle, handle2, XvMCCreateSurface,); |
| 366 |
XW_RSYM(xW, handle, handle2, XvMCDestroySurface,); |
| 367 |
XW_RSYM(xW, handle, handle2, XvMCListSubpictureTypes,); |
| 368 |
XW_RSYM(xW, handle, handle2, XvMCHideSurface,); |
| 369 |
XW_RSYM(xW, handle, handle2, XvMCCreateSubpicture,); |
| 370 |
XW_RSYM(xW, handle, handle2, XvMCClearSubpicture,); |
| 371 |
XW_RSYM(xW, handle, handle2, XvMCCompositeSubpicture,); |
| 372 |
XW_RSYM(xW, handle, handle2, XvMCDestroySubpicture,); |
| 373 |
XW_RSYM(xW, handle, handle2, XvMCSetSubpicturePalette,); |
| 374 |
XW_RSYM(xW, handle, handle2, XvMCBlendSubpicture,); |
| 375 |
XW_RSYM(xW, handle, handle2, XvMCBlendSubpicture2,); |
| 376 |
XW_RSYM(xW, handle, handle2, XvMCPutSurface,); |
| 377 |
XW_RSYM(xW, handle, handle2, XvMCSyncSurface,); |
| 378 |
XW_RSYM(xW, handle, handle2, XvMCFlushSurface,); |
| 379 |
XW_RSYM(xW, handle, handle2, XvMCGetSurfaceStatus,); |
| 380 |
XW_RSYM(xW, handle, handle2, XvMCRenderSurface,); |
| 381 |
XW_RSYM(xW, handle, handle2, XvMCSyncSubpicture,); |
| 382 |
XW_RSYM(xW, handle, handle2, XvMCFlushSubpicture,); |
| 383 |
XW_RSYM(xW, handle, handle2, XvMCGetSubpictureStatus,); |
| 384 |
XW_RSYM(xW, handle, handle2, XvMCCreateBlocks,); |
| 385 |
XW_RSYM(xW, handle, handle2, XvMCDestroyBlocks,); |
| 386 |
XW_RSYM(xW, handle, handle2, XvMCCreateMacroBlocks,); |
| 387 |
XW_RSYM(xW, handle, handle2, XvMCDestroyMacroBlocks,); |
| 388 |
XW_RSYM(xW, handle, handle2, XvMCQueryAttributes,); |
| 389 |
XW_RSYM(xW, handle, handle2, XvMCSetAttribute,); |
| 390 |
XW_RSYM(xW, handle, handle2, XvMCGetAttribute,); |
| 391 |
xW.initialised = 1; |
| 392 |
XW_RSYM2(xW, handle, handle2, XvMCBeginSurface); |
| 393 |
XW_RSYM(xW, handle, handle2, XvMCLoadQMatrix,); |
| 394 |
XW_RSYM(xW, handle, handle2, XvMCPutSlice,); |
| 395 |
XW_RSYM(xW, handle, handle2, XvMCPutSlice2,); |
| 396 |
xW.vldextension = 1; |
| 397 |
} |
| 398 |
|
| 399 |
|
| 400 |
Bool XvMCQueryExtension (Display *display, int *eventBase, int *errBase) |
| 401 |
{ |
| 402 |
if (!wrapperPreInit) preInitW( display ); |
| 403 |
if (!xW.preInitialised) return 0; |
| 404 |
return (*xW.XvMCQueryExtension)(display, eventBase, errBase); |
| 405 |
} |
| 406 |
|
| 407 |
Status XvMCQueryVersion (Display *display, int *major_versionp, |
| 408 |
int *minor_versionp) |
| 409 |
{ |
| 410 |
if (!wrapperPreInit) preInitW( display ); |
| 411 |
if (!xW.preInitialised) return 0; |
| 412 |
return (*xW.XvMCQueryVersion)(display, major_versionp, minor_versionp); |
| 413 |
} |
| 414 |
|
| 415 |
|
| 416 |
XvMCSurfaceInfo * XvMCListSurfaceTypes(Display *dpy, XvPortID port, int *num) |
| 417 |
{ |
| 418 |
if (!wrapperInit) initW( dpy, port); |
| 419 |
if (!xW.initialised) return NULL; |
| 420 |
return (*xW.XvMCListSurfaceTypes)(dpy, port, num); |
| 421 |
} |
| 422 |
|
| 423 |
Status XvMCCreateContext ( |
| 424 |
Display *display, |
| 425 |
XvPortID port, |
| 426 |
int surface_type_id, |
| 427 |
int width, |
| 428 |
int height, |
| 429 |
int flags, |
| 430 |
XvMCContext * context |
| 431 |
) |
| 432 |
{ |
| 433 |
if (!wrapperInit) initW(display, port); |
| 434 |
if (!xW.initialised) return BadValue; |
| 435 |
return (*xW.XvMCCreateContext)(display, port, surface_type_id, |
| 436 |
width, height, flags, context); |
| 437 |
} |
| 438 |
|
| 439 |
Status XvMCDestroyContext (Display *display, XvMCContext * context) |
| 440 |
{ |
| 441 |
if (!xW.initialised) return BadValue; |
| 442 |
return (*xW.XvMCDestroyContext)(display, context); |
| 443 |
} |
| 444 |
|
| 445 |
Status |
| 446 |
XvMCCreateSurface( |
| 447 |
Display *display, |
| 448 |
XvMCContext * context, |
| 449 |
XvMCSurface * surface |
| 450 |
) |
| 451 |
{ |
| 452 |
if (!xW.initialised) return BadValue; |
| 453 |
return (*xW.XvMCCreateSurface)(display, context, surface); |
| 454 |
} |
| 455 |
|
| 456 |
Status XvMCDestroySurface(Display *display, XvMCSurface *surface) |
| 457 |
{ |
| 458 |
if (!xW.initialised) return BadValue; |
| 459 |
return (*xW.XvMCDestroySurface)(display, surface); |
| 460 |
} |
| 461 |
|
| 462 |
|
| 463 |
XvImageFormatValues * XvMCListSubpictureTypes ( |
| 464 |
Display * display, |
| 465 |
XvPortID port, |
| 466 |
int surface_type_id, |
| 467 |
int *count_return |
| 468 |
) |
| 469 |
{ |
| 470 |
if (!xW.initialised) return NULL; |
| 471 |
return (*xW.XvMCListSubpictureTypes)(display, port, surface_type_id, |
| 472 |
count_return); |
| 473 |
} |
| 474 |
|
| 475 |
|
| 476 |
Status |
| 477 |
XvMCPutSurface( |
| 478 |
Display *display, |
| 479 |
XvMCSurface *surface, |
| 480 |
Drawable draw, |
| 481 |
short srcx, |
| 482 |
short srcy, |
| 483 |
unsigned short srcw, |
| 484 |
unsigned short srch, |
| 485 |
short destx, |
| 486 |
short desty, |
| 487 |
unsigned short destw, |
| 488 |
unsigned short desth, |
| 489 |
int flags |
| 490 |
) |
| 491 |
{ |
| 492 |
if (!xW.initialised) return BadValue; |
| 493 |
return (*xW.XvMCPutSurface)(display, surface, draw, srcx, srcy, srcw, srch, |
| 494 |
destx, desty, destw, desth, flags); |
| 495 |
} |
| 496 |
|
| 497 |
Status XvMCHideSurface(Display *display, XvMCSurface *surface) |
| 498 |
{ |
| 499 |
if (!xW.initialised) return BadValue; |
| 500 |
return (*xW.XvMCHideSurface)(display, surface); |
| 501 |
} |
| 502 |
|
| 503 |
|
| 504 |
Status |
| 505 |
XvMCCreateSubpicture ( |
| 506 |
Display *display, |
| 507 |
XvMCContext *context, |
| 508 |
XvMCSubpicture *subpicture, |
| 509 |
unsigned short width, |
| 510 |
unsigned short height, |
| 511 |
int xvimage_id |
| 512 |
) |
| 513 |
{ |
| 514 |
if (!xW.initialised) return BadValue; |
| 515 |
return (*xW.XvMCCreateSubpicture)(display, context, subpicture, width, height, |
| 516 |
xvimage_id); |
| 517 |
} |
| 518 |
|
| 519 |
|
| 520 |
Status |
| 521 |
XvMCClearSubpicture ( |
| 522 |
Display *display, |
| 523 |
XvMCSubpicture *subpicture, |
| 524 |
short x, |
| 525 |
short y, |
| 526 |
unsigned short width, |
| 527 |
unsigned short height, |
| 528 |
unsigned int color |
| 529 |
) |
| 530 |
{ |
| 531 |
if (!xW.initialised) return BadValue; |
| 532 |
return (*xW.XvMCClearSubpicture)(display, subpicture, x, y, width, height, color); |
| 533 |
} |
| 534 |
|
| 535 |
|
| 536 |
Status |
| 537 |
XvMCCompositeSubpicture ( |
| 538 |
Display *display, |
| 539 |
XvMCSubpicture *subpicture, |
| 540 |
XvImage *image, |
| 541 |
short srcx, |
| 542 |
short srcy, |
| 543 |
unsigned short width, |
| 544 |
unsigned short height, |
| 545 |
short dstx, |
| 546 |
short dsty |
| 547 |
) |
| 548 |
{ |
| 549 |
if (!xW.initialised) return BadValue; |
| 550 |
return (*xW.XvMCCompositeSubpicture)(display, subpicture, image, srcx, srcy, |
| 551 |
width, height, dstx, dsty); |
| 552 |
} |
| 553 |
|
| 554 |
Status |
| 555 |
XvMCDestroySubpicture (Display *display, XvMCSubpicture *subpicture) |
| 556 |
{ |
| 557 |
if (!xW.initialised) return BadValue; |
| 558 |
return (*xW.XvMCDestroySubpicture)(display, subpicture); |
| 559 |
} |
| 560 |
|
| 561 |
Status |
| 562 |
XvMCSetSubpicturePalette ( |
| 563 |
Display *display, |
| 564 |
XvMCSubpicture *subpicture, |
| 565 |
unsigned char *palette |
| 566 |
) |
| 567 |
{ |
| 568 |
if (!xW.initialised) return BadValue; |
| 569 |
return (*xW.XvMCSetSubpicturePalette)(display, subpicture, palette); |
| 570 |
} |
| 571 |
|
| 572 |
|
| 573 |
Status |
| 574 |
XvMCBlendSubpicture ( |
| 575 |
Display *display, |
| 576 |
XvMCSurface *target_surface, |
| 577 |
XvMCSubpicture *subpicture, |
| 578 |
short subx, |
| 579 |
short suby, |
| 580 |
unsigned short subw, |
| 581 |
unsigned short subh, |
| 582 |
short surfx, |
| 583 |
short surfy, |
| 584 |
unsigned short surfw, |
| 585 |
unsigned short surfh |
| 586 |
) |
| 587 |
{ |
| 588 |
if (!xW.initialised) return BadValue; |
| 589 |
return (*xW.XvMCBlendSubpicture)(display, target_surface, subpicture, |
| 590 |
subx, suby, subw, subh, surfx, surfy, |
| 591 |
surfw, surfh); |
| 592 |
} |
| 593 |
|
| 594 |
Status |
| 595 |
XvMCBlendSubpicture2 ( |
| 596 |
Display *display, |
| 597 |
XvMCSurface *source_surface, |
| 598 |
XvMCSurface *target_surface, |
| 599 |
XvMCSubpicture *subpicture, |
| 600 |
short subx, |
| 601 |
short suby, |
| 602 |
unsigned short subw, |
| 603 |
unsigned short subh, |
| 604 |
short surfx, |
| 605 |
short surfy, |
| 606 |
unsigned short surfw, |
| 607 |
unsigned short surfh |
| 608 |
) |
| 609 |
{ |
| 610 |
if (!xW.initialised) return BadValue; |
| 611 |
return (*xW.XvMCBlendSubpicture2)(display, source_surface, target_surface, subpicture, |
| 612 |
subx, suby, subw, subh, surfx, surfy, surfw, surfh); |
| 613 |
} |
| 614 |
|
| 615 |
|
| 616 |
Status XvMCSyncSurface (Display *display, XvMCSurface *surface) |
| 617 |
{ |
| 618 |
if (!xW.initialised) return BadValue; |
| 619 |
return (*xW.XvMCSyncSurface)(display, surface); |
| 620 |
} |
| 621 |
|
| 622 |
Status XvMCFlushSurface (Display *display, XvMCSurface *surface) |
| 623 |
{ |
| 624 |
if (!xW.initialised) return BadValue; |
| 625 |
return (*xW.XvMCFlushSurface)(display, surface); |
| 626 |
} |
| 627 |
|
| 628 |
Status XvMCGetSurfaceStatus (Display *display, XvMCSurface *surface, int *stat) |
| 629 |
{ |
| 630 |
if (!xW.initialised) return BadValue; |
| 631 |
return (*xW.XvMCGetSurfaceStatus)(display, surface, stat); |
| 632 |
} |
| 633 |
|
| 634 |
Status XvMCRenderSurface ( |
| 635 |
Display *display, |
| 636 |
XvMCContext *context, |
| 637 |
unsigned int picture_structure, |
| 638 |
XvMCSurface *target_surface, |
| 639 |
XvMCSurface *past_surface, |
| 640 |
XvMCSurface *future_surface, |
| 641 |
unsigned int flags, |
| 642 |
unsigned int num_macroblocks, |
| 643 |
unsigned int first_macroblock, |
| 644 |
XvMCMacroBlockArray *macroblock_array, |
| 645 |
XvMCBlockArray *blocks |
| 646 |
) |
| 647 |
{ |
| 648 |
if (!xW.initialised) return BadValue; |
| 649 |
return (*xW.XvMCRenderSurface)(display, context, picture_structure, target_surface, |
| 650 |
past_surface, future_surface, flags, num_macroblocks, |
| 651 |
first_macroblock, macroblock_array, blocks); |
| 652 |
} |
| 653 |
|
| 654 |
Status XvMCSyncSubpicture (Display *display, XvMCSubpicture *subpicture) |
| 655 |
{ |
| 656 |
if (!xW.initialised) return BadValue; |
| 657 |
return (*xW.XvMCSyncSubpicture)(display, subpicture); |
| 658 |
} |
| 659 |
|
| 660 |
Status XvMCFlushSubpicture (Display *display, XvMCSubpicture *subpicture) |
| 661 |
{ |
| 662 |
if (!xW.initialised) return BadValue; |
| 663 |
return (*xW.XvMCFlushSubpicture)(display, subpicture); |
| 664 |
} |
| 665 |
Status |
| 666 |
XvMCGetSubpictureStatus (Display *display, XvMCSubpicture *subpic, int *stat) |
| 667 |
{ |
| 668 |
if (!xW.initialised) return BadValue; |
| 669 |
return (*xW.XvMCGetSubpictureStatus)(display, subpic, stat); |
| 670 |
} |
| 671 |
|
| 672 |
Status XvMCCreateBlocks ( |
| 673 |
Display *display, |
| 674 |
XvMCContext *context, |
| 675 |
unsigned int num_blocks, |
| 676 |
XvMCBlockArray *block |
| 677 |
) |
| 678 |
{ |
| 679 |
if (!xW.initialised) return BadValue; |
| 680 |
return (*xW.XvMCCreateBlocks)(display, context, num_blocks, block); |
| 681 |
} |
| 682 |
|
| 683 |
|
| 684 |
Status XvMCDestroyBlocks (Display *display,XvMCBlockArray *block) |
| 685 |
{ |
| 686 |
if (!xW.initialised) return BadValue; |
| 687 |
return (*xW.XvMCDestroyBlocks)(display, block); |
| 688 |
} |
| 689 |
|
| 690 |
Status XvMCCreateMacroBlocks ( |
| 691 |
Display *display, |
| 692 |
XvMCContext *context, |
| 693 |
unsigned int num_blocks, |
| 694 |
XvMCMacroBlockArray *blocks |
| 695 |
) |
| 696 |
{ |
| 697 |
if (!xW.initialised) return BadValue; |
| 698 |
return (*xW.XvMCCreateMacroBlocks)(display, context, num_blocks, blocks); |
| 699 |
} |
| 700 |
|
| 701 |
|
| 702 |
Status XvMCDestroyMacroBlocks ( |
| 703 |
Display *display, |
| 704 |
XvMCMacroBlockArray *block |
| 705 |
) |
| 706 |
{ |
| 707 |
if (!xW.initialised) return BadValue; |
| 708 |
return (*xW.XvMCDestroyMacroBlocks)(display, block); |
| 709 |
} |
| 710 |
|
| 711 |
|
| 712 |
XvAttribute * |
| 713 |
XvMCQueryAttributes ( |
| 714 |
Display *display, |
| 715 |
XvMCContext *context, |
| 716 |
int *number |
| 717 |
) |
| 718 |
{ |
| 719 |
if (!xW.initialised) return NULL; |
| 720 |
return (*xW.XvMCQueryAttributes)(display, context, number); |
| 721 |
} |
| 722 |
|
| 723 |
|
| 724 |
Status |
| 725 |
XvMCSetAttribute ( |
| 726 |
Display *display, |
| 727 |
XvMCContext *context, |
| 728 |
Atom attribute, |
| 729 |
int value |
| 730 |
) |
| 731 |
{ |
| 732 |
if (!xW.initialised) return BadValue; |
| 733 |
return (*xW.XvMCSetAttribute)(display, context, attribute, value); |
| 734 |
} |
| 735 |
|
| 736 |
|
| 737 |
Status |
| 738 |
XvMCGetAttribute ( |
| 739 |
Display *display, |
| 740 |
XvMCContext *context, |
| 741 |
Atom attribute, |
| 742 |
int *value |
| 743 |
) |
| 744 |
{ |
| 745 |
if (!xW.initialised) return BadValue; |
| 746 |
return (*xW.XvMCGetAttribute)(display, context, attribute, value); |
| 747 |
} |
| 748 |
|
| 749 |
|
| 750 |
Status XvMCBeginSurface(Display *display, |
| 751 |
XvMCContext *context, |
| 752 |
XvMCSurface *target_surface, |
| 753 |
XvMCSurface *past_surface, |
| 754 |
XvMCSurface *future_surface, |
| 755 |
const XvMCMpegControl *control) |
| 756 |
{ |
| 757 |
if (!xW.vldextension) return BadValue; |
| 758 |
return (*xW.XvMCBeginSurface)(display, context, target_surface, past_surface, future_surface, |
| 759 |
control); |
| 760 |
} |
| 761 |
|
| 762 |
Status XvMCLoadQMatrix(Display *display, XvMCContext *context, |
| 763 |
const XvMCQMatrix *qmx) |
| 764 |
{ |
| 765 |
if (!xW.vldextension) return BadValue; |
| 766 |
return (*xW.XvMCLoadQMatrix)(display, context, qmx); |
| 767 |
} |
| 768 |
|
| 769 |
Status XvMCPutSlice(Display *display,XvMCContext *context, |
| 770 |
char *slice, int nBytes) |
| 771 |
{ |
| 772 |
if (!xW.vldextension) return BadValue; |
| 773 |
return (*xW.XvMCPutSlice)(display, context, slice, nBytes); |
| 774 |
} |
| 775 |
|
| 776 |
Status XvMCPutSlice2(Display *display,XvMCContext *context, |
| 777 |
char *slice, int nBytes, int sliceCode) |
| 778 |
{ |
| 779 |
if (!xW.vldextension) return BadValue; |
| 780 |
return (*xW.XvMCPutSlice2)(display, context, slice, nBytes, sliceCode); |
| 781 |
} |