annotate xv_ext_test.c @ 7:210d197c77f9

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