1 /**************************************************************************
3 * Copyright 2009 Younes Manton.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 /* Force assertions, even on release builds. */
35 int main(int argc
, char **argv
)
37 const unsigned int width
= 16, height
= 16;
38 const unsigned int mc_types
[2] = {XVMC_MOCOMP
| XVMC_MPEG_2
, XVMC_IDCT
| XVMC_MPEG_2
};
43 unsigned int is_overlay
, intra_unsigned
;
46 XvMCSurface surface
= {0};
48 display
= XOpenDisplay(NULL
);
55 XVMC_CHROMA_FORMAT_420
,
64 XCloseDisplay(display
);
65 fprintf(stderr
, "Error, unable to find a good port.\n");
71 Atom xv_colorkey
= XInternAtom(display
, "XV_COLORKEY", 0);
72 XvGetPortAttribute(display
, port_num
, xv_colorkey
, &colorkey
);
75 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
, height
, XVMC_DIRECT
, &context
) == Success
);
77 /* Test NULL context */
78 assert(XvMCCreateSurface(display
, NULL
, &surface
) == XvMCBadContext
);
79 /* Test NULL surface */
80 assert(XvMCCreateSurface(display
, &context
, NULL
) == XvMCBadSurface
);
81 /* Test valid params */
82 assert(XvMCCreateSurface(display
, &context
, &surface
) == Success
);
83 /* Test surface id assigned */
84 assert(surface
.surface_id
!= 0);
85 /* Test context id assigned and correct */
86 assert(surface
.context_id
== context
.context_id
);
87 /* Test surface type id assigned and correct */
88 assert(surface
.surface_type_id
== surface_type_id
);
89 /* Test width & height assigned and correct */
90 assert(surface
.width
== width
&& surface
.height
== height
);
91 /* Test valid params */
92 assert(XvMCDestroySurface(display
, &surface
) == Success
);
93 /* Test NULL surface */
94 assert(XvMCDestroySurface(display
, NULL
) == XvMCBadSurface
);
96 assert(XvMCDestroyContext(display
, &context
) == Success
);
98 XvUngrabPort(display
, port_num
, CurrentTime
);
99 XCloseDisplay(display
);