vdpau: Handle destination rectangles correctly
[mesa/nouveau-pmpeg.git] / src / gallium / state_trackers / vdpau / query.c
blob191e163af8e7d407dd817002c9ae4dd3071abcd3
1 /**************************************************************************
3 * Copyright 2010 Younes Manton.
4 * All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #include <assert.h>
29 #include <math.h>
31 #include "vdpau_private.h"
32 #include "vl_winsys.h"
33 #include "pipe/p_screen.h"
34 #include "pipe/p_defines.h"
35 #include "util/u_debug.h"
37 /**
38 * Retrieve the VDPAU version implemented by the backend.
40 VdpStatus
41 vlVdpGetApiVersion(uint32_t *api_version)
43 if (!api_version)
44 return VDP_STATUS_INVALID_POINTER;
46 *api_version = 1;
47 return VDP_STATUS_OK;
50 /**
51 * Retrieve an implementation-specific string description of the implementation.
52 * This typically includes detailed version information.
54 VdpStatus
55 vlVdpGetInformationString(char const **information_string)
57 if (!information_string)
58 return VDP_STATUS_INVALID_POINTER;
60 *information_string = INFORMATION_STRING;
61 return VDP_STATUS_OK;
64 /**
65 * Query the implementation's VdpVideoSurface capabilities.
67 VdpStatus
68 vlVdpVideoSurfaceQueryCapabilities(VdpDevice device, VdpChromaType surface_chroma_type,
69 VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
71 vlVdpDevice *dev;
72 struct pipe_screen *pscreen;
73 uint32_t max_2d_texture_level;
75 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying VdpVideoSurface capabilities\n");
77 if (!(is_supported && max_width && max_height))
78 return VDP_STATUS_INVALID_POINTER;
80 dev = vlGetDataHTAB(device);
81 if (!dev)
82 return VDP_STATUS_INVALID_HANDLE;
84 pscreen = dev->vscreen->pscreen;
85 if (!pscreen)
86 return VDP_STATUS_RESOURCES;
88 /* XXX: Current limits */
89 *is_supported = true;
90 if (surface_chroma_type != VDP_CHROMA_TYPE_420)
91 *is_supported = false;
93 max_2d_texture_level = pscreen->get_param(pscreen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS);
94 if (!max_2d_texture_level)
95 return VDP_STATUS_RESOURCES;
97 /* I am not quite sure if it is max_2d_texture_level-1 or just max_2d_texture_level */
98 *max_width = *max_height = pow(2,max_2d_texture_level-1);
100 return VDP_STATUS_OK;
104 * Query the implementation's VdpVideoSurface GetBits/PutBits capabilities.
106 VdpStatus
107 vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaType surface_chroma_type,
108 VdpYCbCrFormat bits_ycbcr_format,
109 VdpBool *is_supported)
111 vlVdpDevice *dev;
112 struct pipe_screen *pscreen;
114 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying VdpVideoSurface get/put bits YCbCr capabilities\n");
116 if (!is_supported)
117 return VDP_STATUS_INVALID_POINTER;
119 dev = vlGetDataHTAB(device);
120 if (!dev)
121 return VDP_STATUS_INVALID_HANDLE;
123 pscreen = dev->vscreen->pscreen;
124 if (!pscreen)
125 return VDP_STATUS_RESOURCES;
127 *is_supported = pscreen->is_video_format_supported
129 pscreen,
130 FormatYCBCRToPipe(bits_ycbcr_format),
131 PIPE_VIDEO_PROFILE_UNKNOWN
134 return VDP_STATUS_OK;
138 * Query the implementation's VdpDecoder capabilities.
140 VdpStatus
141 vlVdpDecoderQueryCapabilities(VdpDevice device, VdpDecoderProfile profile,
142 VdpBool *is_supported, uint32_t *max_level, uint32_t *max_macroblocks,
143 uint32_t *max_width, uint32_t *max_height)
145 vlVdpDevice *dev;
146 struct pipe_screen *pscreen;
147 enum pipe_video_profile p_profile;
149 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying VdpDecoder capabilities\n");
151 if (!(is_supported && max_level && max_macroblocks && max_width && max_height))
152 return VDP_STATUS_INVALID_POINTER;
154 dev = vlGetDataHTAB(device);
155 if (!dev)
156 return VDP_STATUS_INVALID_HANDLE;
158 pscreen = dev->vscreen->pscreen;
159 if (!pscreen)
160 return VDP_STATUS_RESOURCES;
162 p_profile = ProfileToPipe(profile);
163 if (p_profile == PIPE_VIDEO_PROFILE_UNKNOWN) {
164 *is_supported = false;
165 return VDP_STATUS_OK;
168 *is_supported = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_CAP_SUPPORTED);
169 if (*is_supported) {
170 *max_width = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_CAP_MAX_WIDTH);
171 *max_height = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_CAP_MAX_HEIGHT);
172 *max_level = 16;
173 *max_macroblocks = (*max_width/16)*(*max_height/16);
174 } else {
175 *max_width = 0;
176 *max_height = 0;
177 *max_level = 0;
178 *max_macroblocks = 0;
181 return VDP_STATUS_OK;
185 * Query the implementation's VdpOutputSurface capabilities.
187 VdpStatus
188 vlVdpOutputSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
189 VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
191 if (!(is_supported && max_width && max_height))
192 return VDP_STATUS_INVALID_POINTER;
194 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying VdpOutputSurface capabilities\n");
196 return VDP_STATUS_NO_IMPLEMENTATION;
200 * Query the implementation's capability to perform a PutBits operation using
201 * application data matching the surface's format.
203 VdpStatus
204 vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
205 VdpBool *is_supported)
207 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying VdpOutputSurface get/put bits native capabilities\n");
209 if (!is_supported)
210 return VDP_STATUS_INVALID_POINTER;
212 return VDP_STATUS_NO_IMPLEMENTATION;
216 * Query the implementation's capability to perform a PutBits operation using
217 * application data in a specific indexed format.
219 VdpStatus
220 vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities(VdpDevice device,
221 VdpRGBAFormat surface_rgba_format,
222 VdpIndexedFormat bits_indexed_format,
223 VdpColorTableFormat color_table_format,
224 VdpBool *is_supported)
226 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying VdpOutputSurface put bits indexed capabilities\n");
228 if (!is_supported)
229 return VDP_STATUS_INVALID_POINTER;
231 return VDP_STATUS_NO_IMPLEMENTATION;
235 * Query the implementation's capability to perform a PutBits operation using
236 * application data in a specific YCbCr/YUB format.
238 VdpStatus
239 vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
240 VdpYCbCrFormat bits_ycbcr_format,
241 VdpBool *is_supported)
243 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying VdpOutputSurface put bits YCbCr capabilities\n");
245 if (!is_supported)
246 return VDP_STATUS_INVALID_POINTER;
248 return VDP_STATUS_NO_IMPLEMENTATION;
252 * Query the implementation's VdpBitmapSurface capabilities.
254 VdpStatus
255 vlVdpBitmapSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
256 VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
258 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying VdpBitmapSurface capabilities\n");
260 if (!(is_supported && max_width && max_height))
261 return VDP_STATUS_INVALID_POINTER;
263 return VDP_STATUS_NO_IMPLEMENTATION;
267 * Query the implementation's support for a specific feature.
269 VdpStatus
270 vlVdpVideoMixerQueryFeatureSupport(VdpDevice device, VdpVideoMixerFeature feature,
271 VdpBool *is_supported)
273 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying VdpVideoMixer feature support\n");
275 if (!is_supported)
276 return VDP_STATUS_INVALID_POINTER;
278 return VDP_STATUS_NO_IMPLEMENTATION;
282 * Query the implementation's support for a specific parameter.
284 VdpStatus
285 vlVdpVideoMixerQueryParameterSupport(VdpDevice device, VdpVideoMixerParameter parameter,
286 VdpBool *is_supported)
288 if (!is_supported)
289 return VDP_STATUS_INVALID_POINTER;
291 return VDP_STATUS_NO_IMPLEMENTATION;
295 * Query the implementation's supported for a specific parameter.
297 VdpStatus
298 vlVdpVideoMixerQueryParameterValueRange(VdpDevice device, VdpVideoMixerParameter parameter,
299 void *min_value, void *max_value)
301 if (!(min_value && max_value))
302 return VDP_STATUS_INVALID_POINTER;
304 return VDP_STATUS_NO_IMPLEMENTATION;
308 * Query the implementation's support for a specific attribute.
310 VdpStatus
311 vlVdpVideoMixerQueryAttributeSupport(VdpDevice device, VdpVideoMixerAttribute attribute,
312 VdpBool *is_supported)
314 if (!is_supported)
315 return VDP_STATUS_INVALID_POINTER;
317 return VDP_STATUS_NO_IMPLEMENTATION;
321 * Query the implementation's supported for a specific attribute.
323 VdpStatus
324 vlVdpVideoMixerQueryAttributeValueRange(VdpDevice device, VdpVideoMixerAttribute attribute,
325 void *min_value, void *max_value)
327 if (!(min_value && max_value))
328 return VDP_STATUS_INVALID_POINTER;
330 return VDP_STATUS_NO_IMPLEMENTATION;