~ubuntu-branches/ubuntu/trusty/libxvmc/trusty-proposed

« back to all changes in this revision

Viewing changes to src/XvMCWrapper.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Stone
  • Date: 2005-12-12 16:17:38 UTC
  • Revision ID: james.westby@ubuntu.com-20051212161738-314g1zk8ag97uoy6
Tags: upstream-0.99.2
Import upstream version 0.99.2

Show diffs side-by-side

added added

removed removed

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