vdpau_private.h revision 2471acfc4c051d480861265011fa5e77fad02887
1/**************************************************************************
2 *
3 * Copyright 2010 Younes Manton & Thomas Balling Sørensen.
4 * All Rights Reserved.
5 *
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:
13 *
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.
17 *
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.
25 *
26 **************************************************************************/
27
28#ifndef VDPAU_PRIVATE_H
29#define VDPAU_PRIVATE_H
30
31#include <vdpau/vdpau.h>
32#include <vdpau/vdpau_x11.h>
33#include <pipe/p_compiler.h>
34#include <pipe/p_video_context.h>
35#include <vl_winsys.h>
36#include <assert.h>
37
38#define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR
39#define QUOTEME(x) #x
40#define TOSTRING(x) QUOTEME(x)
41#define INFORMATION_STRING TOSTRING(INFORMATION)
42#define VL_HANDLES
43
44static inline enum pipe_video_chroma_format
45ChromaToPipe(VdpChromaType vdpau_type)
46{
47   switch (vdpau_type) {
48      case VDP_CHROMA_TYPE_420:
49         return PIPE_VIDEO_CHROMA_FORMAT_420;
50      case VDP_CHROMA_TYPE_422:
51         return PIPE_VIDEO_CHROMA_FORMAT_422;
52      case VDP_CHROMA_TYPE_444:
53         return PIPE_VIDEO_CHROMA_FORMAT_444;
54      default:
55         assert(0);
56   }
57
58   return -1;
59}
60
61static inline VdpChromaType
62PipeToChroma(enum pipe_video_chroma_format pipe_type)
63{
64   switch (pipe_type) {
65      case PIPE_VIDEO_CHROMA_FORMAT_420:
66         return VDP_CHROMA_TYPE_420;
67      case PIPE_VIDEO_CHROMA_FORMAT_422:
68         return VDP_CHROMA_TYPE_422;
69      case PIPE_VIDEO_CHROMA_FORMAT_444:
70         return VDP_CHROMA_TYPE_444;
71      default:
72         assert(0);
73   }
74
75   return -1;
76}
77
78
79static inline enum pipe_format
80FormatToPipe(VdpYCbCrFormat vdpau_format)
81{
82   switch (vdpau_format) {
83      case VDP_YCBCR_FORMAT_NV12:
84         return PIPE_FORMAT_NV12;
85      case VDP_YCBCR_FORMAT_YV12:
86         return PIPE_FORMAT_YV12;
87      case VDP_YCBCR_FORMAT_UYVY:
88         return PIPE_FORMAT_UYVY;
89      case VDP_YCBCR_FORMAT_YUYV:
90         return PIPE_FORMAT_YUYV;
91      case VDP_YCBCR_FORMAT_Y8U8V8A8: /* Not defined in p_format.h */
92         return 0;
93      case VDP_YCBCR_FORMAT_V8U8Y8A8:
94	     return PIPE_FORMAT_VUYA;
95      default:
96         assert(0);
97   }
98
99   return -1;
100}
101
102static inline enum pipe_format
103FormatRGBAToPipe(VdpRGBAFormat vdpau_format)
104{
105   switch (vdpau_format) {
106      case VDP_RGBA_FORMAT_A8:
107         return PIPE_FORMAT_A8_UNORM;
108      case VDP_RGBA_FORMAT_B10G10R10A2:
109         return PIPE_FORMAT_B10G10R10A2_UNORM;
110      case VDP_RGBA_FORMAT_B8G8R8A8:
111         return PIPE_FORMAT_B8G8R8A8_UNORM;
112      case VDP_RGBA_FORMAT_R10G10B10A2:
113         return PIPE_FORMAT_R10G10B10A2_UNORM;
114      case VDP_RGBA_FORMAT_R8G8B8A8:
115         return PIPE_FORMAT_R8G8B8A8_UNORM;
116      default:
117         assert(0);
118   }
119
120   return -1;
121}
122
123static inline VdpYCbCrFormat
124PipeToFormat(enum pipe_format p_format)
125{
126   switch (p_format) {
127      case PIPE_FORMAT_NV12:
128         return VDP_YCBCR_FORMAT_NV12;
129      case PIPE_FORMAT_YV12:
130         return VDP_YCBCR_FORMAT_YV12;
131      case PIPE_FORMAT_UYVY:
132         return VDP_YCBCR_FORMAT_UYVY;
133      case PIPE_FORMAT_YUYV:
134         return VDP_YCBCR_FORMAT_YUYV;
135      //case PIPE_FORMAT_YUVA:
136        // return VDP_YCBCR_FORMAT_Y8U8V8A8;
137      case PIPE_FORMAT_VUYA:
138	 return VDP_YCBCR_FORMAT_V8U8Y8A8;
139      default:
140         assert(0);
141   }
142
143   return -1;
144}
145
146static inline enum pipe_video_profile
147ProfileToPipe(VdpDecoderProfile vdpau_profile)
148{
149   switch (vdpau_profile) {
150      case VDP_DECODER_PROFILE_MPEG1:
151         return PIPE_VIDEO_PROFILE_MPEG1;
152      case VDP_DECODER_PROFILE_MPEG2_SIMPLE:
153         return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE;
154      case VDP_DECODER_PROFILE_MPEG2_MAIN:
155         return PIPE_VIDEO_PROFILE_MPEG2_MAIN;
156      case VDP_DECODER_PROFILE_H264_BASELINE:
157         return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE;
158      case VDP_DECODER_PROFILE_H264_MAIN: /* Not defined in p_format.h */
159         return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN;
160      case VDP_DECODER_PROFILE_H264_HIGH:
161	     return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
162      default:
163         return PIPE_VIDEO_PROFILE_UNKNOWN;
164   }
165}
166
167typedef struct
168{
169   Display *display;
170   int screen;
171   struct vl_screen *vscreen;
172   struct vl_context *context;
173} vlVdpDevice;
174
175typedef struct
176{
177   vlVdpDevice *device;
178   Drawable drawable;
179} vlVdpPresentationQueueTarget;
180
181typedef struct
182{
183   vlVdpDevice *device;
184   Drawable drawable;
185   struct pipe_video_compositor *compositor;
186} vlVdpPresentationQueue;
187
188typedef struct
189{
190   vlVdpDevice *device;
191   struct pipe_video_compositor *compositor;
192} vlVdpVideoMixer;
193
194typedef struct
195{
196   vlVdpDevice *device;
197   struct pipe_video_buffer *video_buffer;
198} vlVdpSurface;
199
200typedef struct
201{
202   vlVdpDevice *device;
203   struct pipe_surface *surface;
204   struct pipe_sampler_view *sampler_view;
205} vlVdpOutputSurface;
206
207typedef struct
208{
209   vlVdpDevice *device;
210   struct pipe_video_decoder *decoder;
211   struct pipe_video_decode_buffer *buffer;
212} vlVdpDecoder;
213
214typedef uint32_t vlHandle;
215
216boolean vlCreateHTAB(void);
217void vlDestroyHTAB(void);
218vlHandle vlAddDataHTAB(void *data);
219void* vlGetDataHTAB(vlHandle handle);
220void vlRemoveDataHTAB(vlHandle handle);
221
222boolean vlGetFuncFTAB(VdpFuncId function_id, void **func);
223
224/* Public functions */
225VdpDeviceCreateX11 vdp_imp_device_create_x11;
226VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11;
227
228/* Internal function pointers */
229VdpGetErrorString vlVdpGetErrorString;
230VdpDeviceDestroy vlVdpDeviceDestroy;
231VdpGetProcAddress vlVdpGetProcAddress;
232VdpGetApiVersion vlVdpGetApiVersion;
233VdpGetInformationString vlVdpGetInformationString;
234VdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities;
235VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities;
236VdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities;
237VdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities;
238VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities;
239VdpOutputSurfaceQueryPutBitsIndexedCapabilities vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities;
240VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities;
241VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities;
242VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport;
243VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport;
244VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange;
245VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport;
246VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange;
247VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate;
248VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy;
249VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters;
250VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr;
251VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr;
252VdpDecoderCreate vlVdpDecoderCreate;
253VdpDecoderDestroy vlVdpDecoderDestroy;
254VdpDecoderGetParameters vlVdpDecoderGetParameters;
255VdpDecoderRender vlVdpDecoderRender;
256VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate;
257VdpOutputSurfaceDestroy vlVdpOutputSurfaceDestroy;
258VdpOutputSurfaceGetParameters vlVdpOutputSurfaceGetParameters;
259VdpOutputSurfaceGetBitsNative vlVdpOutputSurfaceGetBitsNative;
260VdpOutputSurfacePutBitsNative vlVdpOutputSurfacePutBitsNative;
261VdpOutputSurfacePutBitsIndexed vlVdpOutputSurfacePutBitsIndexed;
262VdpOutputSurfacePutBitsYCbCr vlVdpOutputSurfacePutBitsYCbCr;
263VdpOutputSurfaceRenderOutputSurface vlVdpOutputSurfaceRenderOutputSurface;
264VdpOutputSurfaceRenderBitmapSurface vlVdpOutputSurfaceRenderBitmapSurface;
265VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate;
266VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy;
267VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters;
268VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative;
269VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy;
270VdpPresentationQueueCreate vlVdpPresentationQueueCreate;
271VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy;
272VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor;
273VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor;
274VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime;
275VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay;
276VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle;
277VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus;
278VdpPreemptionCallback vlVdpPreemptionCallback;
279VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister;
280VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables;
281VdpVideoMixerCreate vlVdpVideoMixerCreate;
282VdpVideoMixerRender vlVdpVideoMixerRender;
283VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues;
284VdpVideoMixerGetFeatureSupport vlVdpVideoMixerGetFeatureSupport;
285VdpVideoMixerGetFeatureEnables vlVdpVideoMixerGetFeatureEnables;
286VdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues;
287VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues;
288VdpVideoMixerDestroy vlVdpVideoMixerDestroy;
289VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix;
290
291#endif // VDPAU_PRIVATE_H
292