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.
35
int main(int argc, const char* argv[])
40
int major_version, minor_version;
42
dpy = XOpenDisplay(NULL);
44
printf("XOpenDisplay: dpy = %08x\n", dpy);
46
va_dpy = vaGetDisplay(dpy);
48
printf("vaGetDisplay: va_dpy = %08x\n", va_dpy);
50
va_status = vaInitialize(va_dpy, &major_version, &minor_version);
51
ASSERT( VA_STATUS_SUCCESS == va_status );
52
printf("vaInitialize: major = %d minor = %d\n", major_version, minor_version);
55
VASurfaceID surfaces[21];
59
va_status = vaCreateSurfaces(va_dpy, 720, 480, VA_RT_FORMAT_YUV420, 20, surfaces);
60
ASSERT( VA_STATUS_SUCCESS == va_status );
61
ASSERT( -1 == surfaces[20] ); /* bounds check */
62
for(i = 0; i < 20; i++)
64
printf("Surface %d surface_id = %08x\n", i, surfaces[i]);
66
Window win = XCreateSimpleWindow(dpy, RootWindow(dpy, 0), 0, 0, 720, 480, 0, 0, WhitePixel(dpy, 0));
67
printf("Window = %08x\n", win);
71
vaPutSurface(va_dpy, surfaces[0], win, 0, 0, 720, 480, 0, 0, 720, 480, 0);
74
va_status = vaDestroySurface(va_dpy, surfaces, 20);
75
ASSERT( VA_STATUS_SUCCESS == va_status );
81
VAProfile *profiles = malloc(vaMaxNumProfiles(va_dpy) * sizeof(VAProfile));
83
printf("vaMaxNumProfiles = %d\n", vaMaxNumProfiles(va_dpy));
85
va_status = vaQueryConfigProfiles(va_dpy, profiles, &num_profiles);
86
ASSERT( VA_STATUS_SUCCESS == va_status );
88
printf("vaQueryConfigProfiles reports %d profiles\n", num_profiles);
89
for(i = 0; i < num_profiles; i++)
91
printf("Profile %d\n", profiles[i]);
96
VASurfaceID surfaces[20];
98
VAConfigAttrib attrib;
102
attrib.type = VAConfigAttribRTFormat;
103
va_status = vaGetConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD,
105
ASSERT( VA_STATUS_SUCCESS == va_status );
107
ASSERT(attrib.value & VA_RT_FORMAT_YUV420);
108
/* Found desired RT format, keep going */
110
va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, &attrib, 1,
112
ASSERT( VA_STATUS_SUCCESS == va_status );
114
va_status = vaCreateSurfaces(va_dpy, 720, 480, VA_RT_FORMAT_YUV420, 20, surfaces);
115
ASSERT( VA_STATUS_SUCCESS == va_status );
117
va_status = vaCreateContext(va_dpy, config_id, 720, 480, 0 /* flag */, surfaces, 20, &context);
118
ASSERT( VA_STATUS_SUCCESS == va_status );
120
va_status = vaDestroyContext(va_dpy, context);
121
ASSERT( VA_STATUS_SUCCESS == va_status );
123
va_status = vaDestroySurface(va_dpy, surfaces, 20);
124
ASSERT( VA_STATUS_SUCCESS == va_status );
128
VABufferID picture_buf[3];
129
va_status = vaCreateBuffer(va_dpy, VAPictureParameterBufferType, &picture_buf[0]);
130
ASSERT( VA_STATUS_SUCCESS == va_status );
131
va_status = vaCreateBuffer(va_dpy, VAPictureParameterBufferType, &picture_buf[1]);
132
ASSERT( VA_STATUS_SUCCESS == va_status );
133
va_status = vaCreateBuffer(va_dpy, VAPictureParameterBufferType, &picture_buf[2]);
134
ASSERT( VA_STATUS_SUCCESS == va_status );
136
va_status = vaDestroyBuffer(va_dpy, picture_buf[0]);
137
ASSERT( VA_STATUS_SUCCESS == va_status );
138
va_status = vaDestroyBuffer(va_dpy, picture_buf[2]);
139
ASSERT( VA_STATUS_SUCCESS == va_status );
140
va_status = vaDestroyBuffer(va_dpy, picture_buf[1]);
141
ASSERT( VA_STATUS_SUCCESS == va_status );
144
va_status = vaTerminate(va_dpy);
145
ASSERT( VA_STATUS_SUCCESS == va_status );
146
printf("vaTerminate\n");