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 min_required_blocks
= 1, min_required_macroblocks
= 1;
39 const unsigned int mc_types
[2] = {XVMC_MOCOMP
| XVMC_MPEG_2
, XVMC_IDCT
| XVMC_MPEG_2
};
44 unsigned int is_overlay
, intra_unsigned
;
48 XvMCBlockArray blocks
= {0};
49 XvMCMacroBlockArray macroblocks
= {0};
51 display
= XOpenDisplay(NULL
);
58 XVMC_CHROMA_FORMAT_420
,
67 XCloseDisplay(display
);
68 fprintf(stderr
, "Error, unable to find a good port.\n");
74 Atom xv_colorkey
= XInternAtom(display
, "XV_COLORKEY", 0);
75 XvGetPortAttribute(display
, port_num
, xv_colorkey
, &colorkey
);
78 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
, height
, XVMC_DIRECT
, &context
) == Success
);
79 assert(XvMCCreateSurface(display
, &context
, &surface
) == Success
);
81 /* Test NULL context */
82 assert(XvMCCreateBlocks(display
, NULL
, 1, &blocks
) == XvMCBadContext
);
84 assert(XvMCCreateBlocks(display
, &context
, 0, &blocks
) == BadValue
);
85 /* Test valid params */
86 assert(XvMCCreateBlocks(display
, &context
, min_required_blocks
, &blocks
) == Success
);
87 /* Test context id assigned and correct */
88 assert(blocks
.context_id
== context
.context_id
);
89 /* Test number of blocks assigned and correct */
90 assert(blocks
.num_blocks
== min_required_blocks
);
91 /* Test block pointer valid */
92 assert(blocks
.blocks
!= NULL
);
93 /* Test NULL context */
94 assert(XvMCCreateMacroBlocks(display
, NULL
, 1, ¯oblocks
) == XvMCBadContext
);
95 /* Test 0 macroblocks */
96 assert(XvMCCreateMacroBlocks(display
, &context
, 0, ¯oblocks
) == BadValue
);
97 /* Test valid params */
98 assert(XvMCCreateMacroBlocks(display
, &context
, min_required_macroblocks
, ¯oblocks
) == Success
);
99 /* Test context id assigned and correct */
100 assert(macroblocks
.context_id
== context
.context_id
);
101 /* Test macroblock pointer valid */
102 assert(macroblocks
.macro_blocks
!= NULL
);
103 /* Test valid params */
104 assert(XvMCDestroyMacroBlocks(display
, ¯oblocks
) == Success
);
105 /* Test valid params */
106 assert(XvMCDestroyBlocks(display
, &blocks
) == Success
);
108 assert(XvMCDestroySurface(display
, &surface
) == Success
);
109 assert(XvMCDestroyContext(display
, &context
) == Success
);
111 XvUngrabPort(display
, port_num
, CurrentTime
);
112 XCloseDisplay(display
);