5 int main(int argc
, char **argv
)
7 const unsigned int width
= 16, height
= 16;
8 const unsigned int mc_types
[2] = {XVMC_MOCOMP
| XVMC_MPEG_2
, XVMC_IDCT
| XVMC_MPEG_2
};
13 unsigned int is_overlay
, intra_unsigned
;
15 XvMCContext context
= {0};
17 display
= XOpenDisplay(NULL
);
24 XVMC_CHROMA_FORMAT_420
,
33 XCloseDisplay(display
);
34 error(1, 0, "Error, unable to find a good port.\n");
39 Atom xv_colorkey
= XInternAtom(display
, "XV_COLORKEY", 0);
40 XvGetPortAttribute(display
, port_num
, xv_colorkey
, &colorkey
);
43 /* Note: XvMCBadContext not a valid return for XvMCCreateContext in the XvMC API, but openChrome driver returns it */
44 /* Note: Nvidia binary driver segfaults on NULL context, halts with debug output on bad port */
46 /* Test NULL context */
47 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
, height
, XVMC_DIRECT
, NULL
) == XvMCBadContext
);
48 /* Test invalid port */
49 assert(XvMCCreateContext(display
, port_num
+ 1, surface_type_id
, width
, height
, XVMC_DIRECT
, &context
) == XvBadPort
);
50 /* Test invalid surface */
51 assert(XvMCCreateContext(display
, port_num
, surface_type_id
+ 1, width
, height
, XVMC_DIRECT
, &context
) == BadMatch
);
52 /* Test invalid flags */
53 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
, height
, -1, &context
) == BadValue
);
55 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, 16384, height
, XVMC_DIRECT
, &context
) == BadValue
);
56 /* Test huge height */
57 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
, 16384, XVMC_DIRECT
, &context
) == BadValue
);
58 /* Test huge width & height */
59 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, 16384, 16384, XVMC_DIRECT
, &context
) == BadValue
);
60 /* Test valid params */
61 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
, height
, XVMC_DIRECT
, &context
) == Success
);
62 /* Test context id assigned */
63 assert(context
.context_id
!= 0);
64 /* Test surface type id assigned and correct */
65 assert(context
.surface_type_id
== surface_type_id
);
66 /* Test width & height assigned and correct */
67 assert(context
.width
== width
&& context
.height
== height
);
68 /* Test port assigned and correct */
69 assert(context
.port
== port_num
);
70 /* Test flags assigned and correct */
71 assert(context
.flags
== XVMC_DIRECT
);
72 /* Test NULL context */
73 assert(XvMCDestroyContext(display
, NULL
) == XvMCBadContext
);
74 /* Test valid params */
75 assert(XvMCDestroyContext(display
, &context
) == Success
);
76 /* Test awkward but valid width */
77 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
+ 1, height
, XVMC_DIRECT
, &context
) == Success
);
78 assert(context
.width
>= width
+ 1);
79 assert(XvMCDestroyContext(display
, &context
) == Success
);
80 /* Test awkward but valid height */
81 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
, height
+ 1, XVMC_DIRECT
, &context
) == Success
);
82 assert(context
.height
>= height
+ 1);
83 assert(XvMCDestroyContext(display
, &context
) == Success
);
84 /* Test awkward but valid width & height */
85 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
+ 1, height
+ 1, XVMC_DIRECT
, &context
) == Success
);
86 assert(context
.width
>= width
+ 1 && context
.height
>= height
+ 1);
87 assert(XvMCDestroyContext(display
, &context
) == Success
);
89 XvUngrabPort(display
, port_num
, CurrentTime
);
90 XCloseDisplay(display
);