2 * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 int main(int argc, const char* argv[])
41 int major_version, minor_version;
43 dpy = XOpenDisplay(NULL);
45 printf("XOpenDisplay: dpy = %08x\n", dpy);
47 va_dpy = vaGetDisplay(dpy);
49 printf("vaGetDisplay: va_dpy = %08x\n", va_dpy);
51 va_status = vaInitialize(va_dpy, &major_version, &minor_version);
52 ASSERT( VA_STATUS_SUCCESS == va_status );
53 printf("vaInitialize: major = %d minor = %d\n", major_version, minor_version);
56 VASurfaceID surfaces[21];
60 va_status = vaCreateSurfaces(va_dpy, 720, 480, VA_RT_FORMAT_YUV420, 20, surfaces);
61 ASSERT( VA_STATUS_SUCCESS == va_status );
62 ASSERT( -1 == surfaces[20] ); /* bounds check */
63 for(i = 0; i < 20; i++)
65 printf("Surface %d surface_id = %08x\n", i, surfaces[i]);
67 Window win = XCreateSimpleWindow(dpy, RootWindow(dpy, 0), 0, 0, 720, 480, 0, 0, WhitePixel(dpy, 0));
68 printf("Window = %08x\n", win);
72 vaPutSurface(va_dpy, surfaces[0], win, 0, 0, 720, 480, 0, 0, 720, 480, 0);
75 va_status = vaDestroySurface(va_dpy, surfaces, 20);
76 ASSERT( VA_STATUS_SUCCESS == va_status );
82 VAProfile *profiles = malloc(vaMaxNumProfiles(va_dpy) * sizeof(VAProfile));
84 printf("vaMaxNumProfiles = %d\n", vaMaxNumProfiles(va_dpy));
86 va_status = vaQueryConfigProfiles(va_dpy, profiles, &num_profiles);
87 ASSERT( VA_STATUS_SUCCESS == va_status );
89 printf("vaQueryConfigProfiles reports %d profiles\n", num_profiles);
90 for(i = 0; i < num_profiles; i++)
92 printf("Profile %d\n", profiles[i]);
97 VASurfaceID surfaces[20];
99 VAConfigAttrib attrib;
100 VAConfigID config_id;
103 attrib.type = VAConfigAttribRTFormat;
104 va_status = vaGetConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD,
106 ASSERT( VA_STATUS_SUCCESS == va_status );
108 ASSERT(attrib.value & VA_RT_FORMAT_YUV420);
109 /* Found desired RT format, keep going */
111 va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, &attrib, 1,
113 ASSERT( VA_STATUS_SUCCESS == va_status );
115 va_status = vaCreateSurfaces(va_dpy, 720, 480, VA_RT_FORMAT_YUV420, 20, surfaces);
116 ASSERT( VA_STATUS_SUCCESS == va_status );
118 va_status = vaCreateContext(va_dpy, config_id, 720, 480, 0 /* flag */, surfaces, 20, &context);
119 ASSERT( VA_STATUS_SUCCESS == va_status );
121 va_status = vaDestroyContext(va_dpy, context);
122 ASSERT( VA_STATUS_SUCCESS == va_status );
124 va_status = vaDestroySurface(va_dpy, surfaces, 20);
125 ASSERT( VA_STATUS_SUCCESS == va_status );
129 VABufferID picture_buf[3];
130 va_status = vaCreateBuffer(va_dpy, VAPictureParameterBufferType, &picture_buf[0]);
131 ASSERT( VA_STATUS_SUCCESS == va_status );
132 va_status = vaCreateBuffer(va_dpy, VAPictureParameterBufferType, &picture_buf[1]);
133 ASSERT( VA_STATUS_SUCCESS == va_status );
134 va_status = vaCreateBuffer(va_dpy, VAPictureParameterBufferType, &picture_buf[2]);
135 ASSERT( VA_STATUS_SUCCESS == va_status );
137 va_status = vaDestroyBuffer(va_dpy, picture_buf[0]);
138 ASSERT( VA_STATUS_SUCCESS == va_status );
139 va_status = vaDestroyBuffer(va_dpy, picture_buf[2]);
140 ASSERT( VA_STATUS_SUCCESS == va_status );
141 va_status = vaDestroyBuffer(va_dpy, picture_buf[1]);
142 ASSERT( VA_STATUS_SUCCESS == va_status );
145 va_status = vaTerminate(va_dpy);
146 ASSERT( VA_STATUS_SUCCESS == va_status );
147 printf("vaTerminate\n");