vdpau_private.h revision 49f4aff75ce781fb71383a5ffe44e51e34ff1bf3
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 enum pipe_video_chroma_format TypeToPipe(VdpChromaType vdpau_type)
45{
46   switch (vdpau_type) {
47      case VDP_CHROMA_TYPE_420:
48         return PIPE_VIDEO_CHROMA_FORMAT_420;
49      case VDP_CHROMA_TYPE_422:
50         return PIPE_VIDEO_CHROMA_FORMAT_422;
51      case VDP_CHROMA_TYPE_444:
52         return PIPE_VIDEO_CHROMA_FORMAT_444;
53      default:
54         assert(0);
55   }
56
57   return -1;
58}
59
60static VdpChromaType PipeToType(enum pipe_video_chroma_format pipe_type)
61{
62   switch (pipe_type) {
63      case PIPE_VIDEO_CHROMA_FORMAT_420:
64         return VDP_CHROMA_TYPE_420;
65      case PIPE_VIDEO_CHROMA_FORMAT_422:
66         return VDP_CHROMA_TYPE_422;
67      case PIPE_VIDEO_CHROMA_FORMAT_444:
68         return VDP_CHROMA_TYPE_444;
69      default:
70         assert(0);
71   }
72
73   return -1;
74}
75
76
77static enum pipe_format FormatToPipe(VdpYCbCrFormat vdpau_format)
78{
79   switch (vdpau_format) {
80      case VDP_YCBCR_FORMAT_NV12:
81         return PIPE_FORMAT_NV12;
82      case VDP_YCBCR_FORMAT_YV12:
83         return PIPE_FORMAT_YV12;
84      case VDP_YCBCR_FORMAT_UYVY:
85         return PIPE_FORMAT_UYVY;
86      case VDP_YCBCR_FORMAT_YUYV:
87         return PIPE_FORMAT_YUYV;
88      case VDP_YCBCR_FORMAT_Y8U8V8A8: /* Not defined in p_format.h */
89         return 0;
90      case VDP_YCBCR_FORMAT_V8U8Y8A8:
91	     return PIPE_FORMAT_VUYA;
92      default:
93         assert(0);
94   }
95
96   return -1;
97}
98
99static enum pipe_format FormatRGBAToPipe(VdpRGBAFormat vdpau_format)
100{
101   switch (vdpau_format) {
102      case VDP_RGBA_FORMAT_A8:
103         return PIPE_FORMAT_A8_UNORM;
104      case VDP_RGBA_FORMAT_B10G10R10A2:
105         return PIPE_FORMAT_B10G10R10A2_UNORM;
106      case VDP_RGBA_FORMAT_B8G8R8A8:
107         return PIPE_FORMAT_B8G8R8A8_UNORM;
108      case VDP_RGBA_FORMAT_R10G10B10A2:
109         return PIPE_FORMAT_R10G10B10A2_UNORM;
110      case VDP_RGBA_FORMAT_R8G8B8A8:
111         return PIPE_FORMAT_R8G8B8A8_UNORM;
112      default:
113         assert(0);
114   }
115
116   return -1;
117}
118
119static VdpYCbCrFormat PipeToFormat(enum pipe_format p_format)
120{
121   switch (p_format) {
122      case PIPE_FORMAT_NV12:
123         return VDP_YCBCR_FORMAT_NV12;
124      case PIPE_FORMAT_YV12:
125         return VDP_YCBCR_FORMAT_YV12;
126      case PIPE_FORMAT_UYVY:
127         return VDP_YCBCR_FORMAT_UYVY;
128      case PIPE_FORMAT_YUYV:
129         return VDP_YCBCR_FORMAT_YUYV;
130      //case PIPE_FORMAT_YUVA:
131        // return VDP_YCBCR_FORMAT_Y8U8V8A8;
132      case PIPE_FORMAT_VUYA:
133	 return VDP_YCBCR_FORMAT_V8U8Y8A8;
134      default:
135         assert(0);
136   }
137
138   return -1;
139}
140
141static enum pipe_video_profile ProfileToPipe(VdpDecoderProfile vdpau_profile)
142{
143   switch (vdpau_profile) {
144      case VDP_DECODER_PROFILE_MPEG1:
145         return PIPE_VIDEO_PROFILE_MPEG1;
146      case VDP_DECODER_PROFILE_MPEG2_SIMPLE:
147         return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE;
148      case VDP_DECODER_PROFILE_MPEG2_MAIN:
149         return PIPE_VIDEO_PROFILE_MPEG2_MAIN;
150      case VDP_DECODER_PROFILE_H264_BASELINE:
151         return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE;
152      case VDP_DECODER_PROFILE_H264_MAIN: /* Not defined in p_format.h */
153         return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN;
154      case VDP_DECODER_PROFILE_H264_HIGH:
155	     return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
156      default:
157         PIPE_VIDEO_PROFILE_UNKNOWN;
158   }
159
160   return -1;
161}
162
163typedef struct
164{
165   Display *display;
166   int screen;
167   struct vl_screen *vscreen;
168} vlVdpDevice;
169
170typedef struct
171{
172   vlVdpDevice *device;
173   Drawable drawable;
174} vlVdpPresentationQueueTarget;
175
176typedef struct
177{
178   vlVdpDevice *device;
179   Drawable drawable;
180} vlVdpPresentationQueue;
181
182typedef struct
183{
184   vlVdpDevice *device;
185} vlVdpVideoMixer;
186
187typedef struct
188{
189   vlVdpDevice *device;
190   uint32_t width;
191   uint32_t height;
192   uint32_t pitch;
193   struct pipe_surface *psurface;
194   enum pipe_video_chroma_format chroma_format;
195   uint8_t *data;
196} vlVdpSurface;
197
198typedef struct
199{
200   vlVdpDevice *device;
201   uint32_t width;
202   uint32_t height;
203   enum pipe_format format;
204} vlVdpOutputSurface;
205
206typedef struct
207{
208   vlVdpDevice *device;
209   struct vl_context *vctx;
210   enum pipe_video_chroma_format chroma_format;
211   enum pipe_video_profile profile;
212   uint32_t width;
213   uint32_t height;
214} vlVdpDecoder;
215
216typedef uint32_t vlHandle;
217
218boolean vlCreateHTAB(void);
219void vlDestroyHTAB(void);
220vlHandle vlAddDataHTAB(void *data);
221void* vlGetDataHTAB(vlHandle handle);
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;
239VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities;
240VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities;
241VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport;
242VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport;
243VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange;
244VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport;
245VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange;
246VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate;
247VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy;
248VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters;
249VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr;
250VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr;
251VdpDecoderCreate vlVdpDecoderCreate;
252VdpDecoderDestroy vlVdpDecoderDestroy;
253VdpDecoderRender vlVdpDecoderRender;
254VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate;
255VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate;
256VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy;
257VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters;
258VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative;
259VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy;
260VdpPresentationQueueCreate vlVdpPresentationQueueCreate;
261VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy;
262VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor;
263VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor;
264VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime;
265VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay;
266VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle;
267VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus;
268VdpPreemptionCallback vlVdpPreemptionCallback;
269VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister;
270VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables;
271VdpVideoMixerCreate vlVdpVideoMixerCreate;
272VdpVideoMixerRender vlVdpVideoMixerRender;
273VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues;
274VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix;
275
276#endif // VDPAU_PRIVATE_H
277