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 TUNGSTEN GRAPHICS 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 **************************************************************************/
32 int main(int argc
, char **argv
)
34 const unsigned int width
= 16, height
= 16;
35 const unsigned int min_required_blocks
= 1, min_required_macroblocks
= 1;
36 const unsigned int mc_types
[2] = {XVMC_MOCOMP
| XVMC_MPEG_2
, XVMC_IDCT
| XVMC_MPEG_2
};
41 unsigned int is_overlay
, intra_unsigned
;
45 XvMCBlockArray blocks
= {0};
46 XvMCMacroBlockArray macroblocks
= {0};
48 display
= XOpenDisplay(NULL
);
55 XVMC_CHROMA_FORMAT_420
,
64 XCloseDisplay(display
);
65 error(1, 0, "Error, unable to find a good port.\n");
70 Atom xv_colorkey
= XInternAtom(display
, "XV_COLORKEY", 0);
71 XvGetPortAttribute(display
, port_num
, xv_colorkey
, &colorkey
);
74 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
, height
, XVMC_DIRECT
, &context
) == Success
);
75 assert(XvMCCreateSurface(display
, &context
, &surface
) == Success
);
77 /* Test NULL context */
78 assert(XvMCCreateBlocks(display
, NULL
, 1, &blocks
) == XvMCBadContext
);
80 assert(XvMCCreateBlocks(display
, &context
, 0, &blocks
) == BadValue
);
81 /* Test valid params */
82 assert(XvMCCreateBlocks(display
, &context
, min_required_blocks
, &blocks
) == Success
);
83 /* Test context id assigned and correct */
84 assert(blocks
.context_id
== context
.context_id
);
85 /* Test number of blocks assigned and correct */
86 assert(blocks
.num_blocks
== min_required_blocks
);
87 /* Test block pointer valid */
88 assert(blocks
.blocks
!= NULL
);
89 /* Test NULL context */
90 assert(XvMCCreateMacroBlocks(display
, NULL
, 1, ¯oblocks
) == XvMCBadContext
);
91 /* Test 0 macroblocks */
92 assert(XvMCCreateMacroBlocks(display
, &context
, 0, ¯oblocks
) == BadValue
);
93 /* Test valid params */
94 assert(XvMCCreateMacroBlocks(display
, &context
, min_required_macroblocks
, ¯oblocks
) == Success
);
95 /* Test context id assigned and correct */
96 assert(macroblocks
.context_id
== context
.context_id
);
97 /* Test macroblock pointer valid */
98 assert(macroblocks
.macro_blocks
!= NULL
);
99 /* Test valid params */
100 assert(XvMCDestroyMacroBlocks(display
, ¯oblocks
) == Success
);
101 /* Test valid params */
102 assert(XvMCDestroyBlocks(display
, &blocks
) == Success
);
104 assert(XvMCDestroySurface(display
, &surface
) == Success
);
105 assert(XvMCDestroyContext(display
, &context
) == Success
);
107 XvUngrabPort(display
, port_num
, CurrentTime
);
108 XCloseDisplay(display
);