Mercurial > ~darius > hgwebdir.cgi > simpletv
comparison xv_ext_test.c @ 1:769b155a34f9 SIMPETV_0_1
Initial revision
author | darius |
---|---|
date | Tue, 04 Jan 2005 05:17:43 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:da66cf40a013 | 1:769b155a34f9 |
---|---|
1 #include <stdio.h> | |
2 #include <X11/Intrinsic.h> | |
3 #include <X11/extensions/Xvlib.h> | |
4 | |
5 char *XvAdaptorTypeMaskToString( int mask ) | |
6 { | |
7 static char buf[160]; | |
8 | |
9 buf[0] = '\0'; | |
10 if ( mask & XvInputMask ) sprintf( buf+strlen(buf), "XvInputMask, " ); | |
11 if ( mask & XvOutputMask ) sprintf( buf+strlen(buf), "XvOutputMask, " ); | |
12 if ( mask & XvVideoMask ) sprintf( buf+strlen(buf), "XvVideoMask, " ); | |
13 if ( mask & XvStillMask ) sprintf( buf+strlen(buf), "XvStillMask, " ); | |
14 if ( mask & XvImageMask ) sprintf( buf+strlen(buf), "XvImageMask, " ); | |
15 | |
16 if ( buf[0] ) | |
17 buf[ strlen(buf)-2 ] = '\0'; | |
18 return buf; | |
19 } | |
20 | |
21 int main() | |
22 { | |
23 Display *display; | |
24 XvImageFormatValues *formats; | |
25 XvAdaptorInfo *adaptors; | |
26 int num_adaptors, num_formats; | |
27 int i,j; | |
28 unsigned int xv_version, xv_release, xv_request_base, | |
29 xv_event_base, xv_error_base; | |
30 | |
31 display = XOpenDisplay(NULL); | |
32 | |
33 /* XvQueryVersion */ | |
34 if ( XvQueryExtension( display, | |
35 &xv_version, &xv_release, &xv_request_base, | |
36 &xv_event_base, &xv_error_base ) != Success ) { | |
37 fprintf( stderr, "XvQueryExtension failed\n" ); | |
38 exit(1); | |
39 } | |
40 printf( "\nXvQueryExtension():\n" ); | |
41 printf( " version = %d, release = %d, request_base = %d,\n", | |
42 xv_version, xv_release, xv_request_base ); | |
43 printf( " event_base = %d, error_base = %d\n", | |
44 xv_event_base, xv_error_base ); | |
45 | |
46 /* XvQueryAdaptors */ | |
47 XvQueryAdaptors( display, DefaultRootWindow(display), &num_adaptors, | |
48 &adaptors); | |
49 | |
50 printf( "\nXvQueryAdaptors():\n" ); | |
51 for ( i = 0; i < num_adaptors; i++ ) { | |
52 printf( " Adaptor %2d:\n", i ); | |
53 printf( " base_id = %ld\n", adaptors[i].base_id ); | |
54 printf( " num_ports = %ld\n", adaptors[i].num_ports ); | |
55 printf( " type = %d (%s)\n", | |
56 adaptors[i].type, | |
57 XvAdaptorTypeMaskToString( adaptors[i].type ) ); | |
58 printf( " name = %s\n", adaptors[i].name ); | |
59 printf( " num_adaptors = %ld\n", adaptors[i].num_adaptors); | |
60 printf( " num_formats = %ld\n", adaptors[i].num_formats); | |
61 printf( " formats =\n" ); | |
62 | |
63 for ( j = 0; j < adaptors[i].num_formats; j++ ) | |
64 printf( " Format %2d: depth = %.2d, visual_id = 0x%.2lx\n", | |
65 j, | |
66 adaptors[i].formats[j].depth, | |
67 adaptors[i].formats[j].visual_id ); | |
68 } | |
69 | |
70 /* XvListImageFormats */ | |
71 printf( "\nXvListImageFormats():\n" ); | |
72 for ( i = 0; i < num_adaptors; i++ ) { | |
73 printf( " Adaptor %2d:\n", i ); | |
74 formats = XvListImageFormats( display, adaptors[i].base_id, | |
75 &num_formats ); | |
76 printf( " num_formats = %d\n", num_formats ); | |
77 for ( j = 0; j < num_formats; j++ ) { | |
78 printf( " Format %2d:\n", j ); | |
79 printf( " id = %d\n", formats[j].id ); | |
80 printf( " type = %d (%s)\n", formats[j].type, | |
81 formats[j].type == XvRGB ? "XvRGB" : "XvYUV" ); | |
82 printf( " byte_order = %d (%s)\n", | |
83 formats[j].byte_order, | |
84 formats[j].byte_order == LSBFirst ? "LSBFirst" : "MSBFirst" ); | |
85 printf( " guid = %.4s\n", formats[j].guid ); | |
86 printf( " bits_per_pixel = %d\n", formats[j].bits_per_pixel ); | |
87 printf( " format = %d (%s)\n", formats[j].format, | |
88 formats[j].format == XvPacked ? "XvPacked" : "XvPlanar" ); | |
89 printf( " num_planes = %d\n", formats[j].num_planes ); | |
90 | |
91 if ( formats[j].type == XvRGB ) { | |
92 printf( " depth = %d\n", formats[j].depth ); | |
93 printf( " red_mask = %x\n", formats[j].red_mask ); | |
94 printf( " green_mask = %x\n", formats[j].green_mask ); | |
95 printf( " blue_mask = %x\n", formats[j].blue_mask ); | |
96 } | |
97 if ( formats[j].type == XvYUV ) { | |
98 printf( " sample_bits (yuv) = ( %d, %d, %d )\n", | |
99 formats[j].y_sample_bits, | |
100 formats[j].u_sample_bits, | |
101 formats[j].v_sample_bits ); | |
102 printf( " horz_period (yuv) = ( %d, %d, %d )\n", | |
103 formats[j].horz_y_period, | |
104 formats[j].horz_u_period, | |
105 formats[j].horz_v_period ); | |
106 printf( " vert_period = ( %d, %d, %d )\n", | |
107 formats[j].vert_y_period, | |
108 formats[j].vert_u_period, | |
109 formats[j].vert_v_period ); | |
110 printf( " component_order = %.32s\n", | |
111 formats[j].component_order ); | |
112 printf( " scanline_order = %d\n", formats[j].scanline_order ); | |
113 } | |
114 } | |
115 } | |
116 | |
117 XvFreeAdaptorInfo( adaptors ); | |
118 return(0); | |
119 } | |
120 |