5 void test(int pred, const char *pred_string, const char *doc_string, const char *file, unsigned int line)
7 fputs(doc_string, stderr);
9 fprintf(stderr, " FAIL!\n\t\"%s\" at %s:%u\n", pred_string, file, line);
11 fputs(" PASS!\n", stderr);
20 unsigned int chroma_format,
21 const unsigned int *mc_types,
22 unsigned int num_mc_types,
25 unsigned int *is_overlay,
26 unsigned int *intra_unsigned
29 unsigned int found_port = 0;
30 XvAdaptorInfo *adaptor_info;
31 unsigned int num_adaptors;
33 int ev_base, err_base;
34 unsigned int i, j, k, l;
36 if (!XvMCQueryExtension(display, &ev_base, &err_base))
38 if (XvQueryAdaptors(display, XDefaultRootWindow(display), &num_adaptors, &adaptor_info) != Success)
41 for (i = 0; i < num_adaptors && !found_port; ++i)
43 if (adaptor_info[i].type & XvImageMask)
45 XvMCSurfaceInfo *surface_info = XvMCListSurfaceTypes(display, adaptor_info[i].base_id, &num_types);
49 for (j = 0; j < num_types && !found_port; ++j)
53 surface_info[j].chroma_format == chroma_format &&
54 surface_info[j].max_width >= width &&
55 surface_info[j].max_height >= height
58 for (k = 0; k < num_mc_types && !found_port; ++k)
60 if (surface_info[j].mc_type == mc_types[k])
62 for (l = 0; l < adaptor_info[i].num_ports && !found_port; ++l)
64 if (XvGrabPort(display, adaptor_info[i].base_id + l, CurrentTime) == Success)
66 *port_id = adaptor_info[i].base_id + l;
67 *surface_type_id = surface_info[j].surface_type_id;
68 *is_overlay = surface_info[j].flags & XVMC_OVERLAID_SURFACE;
69 *intra_unsigned = surface_info[j].flags & XVMC_INTRA_UNSIGNED;
83 XvFreeAdaptorInfo(adaptor_info);
88 unsigned int align(unsigned int value, unsigned int alignment)
90 return (value + alignment - 1) & ~(alignment - 1);
93 /* From the glibc manual */
94 int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y)
96 /* Perform the carry for the later subtraction by updating y. */
97 if (x->tv_usec < y->tv_usec)
99 int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
100 y->tv_usec -= 1000000 * nsec;
103 if (x->tv_usec - y->tv_usec > 1000000)
105 int nsec = (x->tv_usec - y->tv_usec) / 1000000;
106 y->tv_usec += 1000000 * nsec;
111 * Compute the time remaining to wait.
112 * tv_usec is certainly positive.
114 result->tv_sec = x->tv_sec - y->tv_sec;
115 result->tv_usec = x->tv_usec - y->tv_usec;
117 /* Return 1 if result is negative. */
118 return x->tv_sec < y->tv_sec;