]>
Commit | Line | Data |
---|---|---|
eb0a02b4 ER |
1 | /* |
2 | ** XvMC extension info program | |
3 | ** | |
4 | ** author: | |
5 | ** Michal Podsiadlik <michal (et) gov.one.pl> | |
6 | ** Ken Harris : fixed some bugs with the "chroma" and "codec" fields, 2005-10-01 | |
7 | ** | |
8 | ** compile using this command (I hope ;-)) | |
9 | ** gcc -o xvmcinfo xvmcinfo.c -lXvMCW | |
10 | * */ | |
11 | ||
12 | #include <stdlib.h> | |
13 | #include <stdio.h> | |
14 | #include <string.h> | |
15 | ||
16 | #include <X11/Xlib.h> | |
17 | #include <X11/extensions/XvMClib.h> | |
18 | ||
19 | void usage(char *c) | |
20 | { | |
21 | fprintf(stderr, "usage:\n" "%s [-display displayname]\n", c); | |
22 | exit(1); | |
23 | } | |
24 | ||
25 | int main(int argc, char **argv) | |
26 | { | |
27 | Display *xserver; | |
28 | int iscreen; | |
29 | char *display = NULL; | |
30 | ||
31 | if (argc != 1 && argc != 3) | |
32 | usage(argv[0]); | |
33 | ||
34 | if (argc == 3) { | |
35 | if (!strcmp(argv[1], "-display")) | |
36 | display = argv[2]; | |
37 | else | |
38 | usage(argv[0]); | |
39 | } | |
40 | ||
41 | xserver = XOpenDisplay(display); | |
42 | if (!xserver) { | |
43 | fprintf(stderr, "failed to connect to display: %s\n", display); | |
44 | return 1; | |
45 | } | |
46 | ||
47 | { | |
48 | unsigned int xv_major, xv_minor, x, y, z; | |
49 | if (XvQueryExtension(xserver, &xv_major, &xv_minor, &x, &y, &z) != | |
50 | Success) { | |
51 | fprintf(stderr, "no Xv extension available\n"); | |
52 | XCloseDisplay(xserver); | |
53 | return 1; | |
54 | } | |
55 | printf("\n" "Xv version %i.%i\n", xv_major, xv_minor); | |
56 | } | |
57 | ||
58 | { | |
59 | int xvmc_major, xvmc_minor; | |
60 | if (XvMCQueryVersion(xserver, &xvmc_major, &xvmc_minor) != Success) { | |
61 | fprintf(stderr, "no XvMC extension available\n"); | |
62 | XCloseDisplay(xserver); | |
63 | return 1; | |
64 | } | |
65 | ||
66 | printf("XvMC version %i.%i\n\n", xvmc_major, xvmc_minor); | |
67 | } | |
68 | ||
69 | for (iscreen = 0; iscreen < ScreenCount(xserver); iscreen++) { | |
70 | unsigned int iadapt, num_adaptors; | |
71 | XvAdaptorInfo *adaptor_info; | |
72 | ||
73 | printf("screen number %i\n", iscreen); | |
74 | ||
75 | XvQueryAdaptors(xserver, RootWindow(xserver, iscreen), | |
76 | &num_adaptors, &adaptor_info); | |
77 | ||
78 | if (!num_adaptors) { | |
79 | printf(" no Xv adaptors found\n"); | |
80 | continue; | |
81 | } | |
82 | ||
83 | for (iadapt = 0; iadapt < num_adaptors; iadapt++) { | |
84 | int isurf, num_surfaces; | |
85 | XvMCSurfaceInfo *xvmc_info; | |
86 | ||
87 | printf(" info for adaptor %i [%s]\n", iadapt, | |
88 | adaptor_info[iadapt].name); | |
89 | ||
90 | xvmc_info = | |
91 | XvMCListSurfaceTypes(xserver, adaptor_info[iadapt].base_id, | |
92 | &num_surfaces); | |
93 | ||
94 | printf(" number of XvMC surface types: %i\n\n", | |
95 | num_surfaces); | |
96 | ||
97 | for (isurf = 0; isurf < num_surfaces; isurf++) { | |
98 | static char *codec[] = { "", "MPEG1", "MPEG2", "H263", "MPEG4" }; // XXXX HACK | |
99 | static char *chroma[] = { "", "XVMC_CHROMA_FORMAT_420 ", "XVMC_CHROMA_FORMAT_422 ", "XVMC_CHROMA_FORMAT_444 " }; // XXXX HACK | |
100 | printf(" info about surface %i:\n" | |
101 | " max_width=%i\n" | |
102 | " max_height=%i\n" | |
103 | " subpicture_max_width=%i\n" | |
104 | " subpicture_max_height=%i\n" | |
105 | " chroma_format:\n" | |
106 | " %s\n" | |
107 | " mc_type:\n" | |
108 | " format : %s\n" | |
109 | " accelaration start from : %s\n" | |
110 | " flags:\n" | |
111 | " %s%s%s%s\n\n", | |
112 | isurf, | |
113 | xvmc_info[isurf].max_width, | |
114 | xvmc_info[isurf].max_height, | |
115 | xvmc_info[isurf].subpicture_max_width, | |
116 | xvmc_info[isurf].subpicture_max_height, | |
117 | /* chroma_format */ | |
118 | chroma[xvmc_info[isurf].chroma_format & 0xf], | |
119 | /* mc_type */ | |
120 | codec[xvmc_info[isurf].mc_type & 0xf], | |
121 | xvmc_info[isurf].mc_type & XVMC_IDCT ? "IDCT " : "MOCOMP ", | |
122 | /* flags */ | |
123 | xvmc_info[isurf].flags & XVMC_OVERLAID_SURFACE ? "XVMC_OVERLAID_SURFACE " : "", | |
124 | xvmc_info[isurf].flags & XVMC_BACKEND_SUBPICTURE ? "XVMC_BACKEND_SUBPICTURE " : "", | |
125 | xvmc_info[isurf].flags & XVMC_SUBPICTURE_INDEPENDENT_SCALING ? "XVMC_SUBPICTURE_INDEPENDENT_SCALING " : "", | |
126 | xvmc_info[isurf].flags & XVMC_INTRA_UNSIGNED ? "XVMC_INTRA_UNSIGNED " : ""); | |
127 | } | |
128 | XFree(xvmc_info); | |
129 | } | |
130 | XvFreeAdaptorInfo(adaptor_info); | |
131 | } | |
132 | XCloseDisplay(xserver); | |
133 | return 0; | |
134 | } |