forked from i-rinat/libvdpau-va-gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvdpau-soft.h
223 lines (205 loc) · 10.5 KB
/
vdpau-soft.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/*
* Copyright 2013 Rinat Ibragimov
*
* This file is part of libvdpau-va-gl
*
* libvdpau-va-gl is distributed under the terms of the LGPLv3. See COPYING for details.
*/
#ifndef VDPAU_SOFT_H_
#define VDPAU_SOFT_H_
#include <GL/glx.h>
#include <pthread.h>
#include <vdpau/vdpau.h>
#include <va/va.h>
#include "handle-storage.h"
#define MAX_RENDER_TARGETS 21
#define NUM_RENDER_TARGETS_H264 21
#define PRESENTATION_QUEUE_LENGTH 10
/** @brief VdpDevice object parameters */
typedef struct {
HandleType type; ///< common type field
void *self; ///< link to device. For VdpDeviceData this is link to itself
pthread_mutex_t lock;
int refcount;
Display *display; ///< own X display connection
Display *display_orig; ///< supplied X display connection
int screen; ///< X screen
GLXContext root_glc; ///< master GL context
Window root; ///< X drawable (root window) used for offscreen drawing
VADisplay va_dpy; ///< VA display
int va_available; ///< 1 if VA-API available
int va_version_major;
int va_version_minor;
GLuint watermark_tex_id; ///< GL texture id for watermark
} VdpDeviceData;
/** @brief VdpVideoMixer object parameters */
typedef struct {
HandleType type; ///< handle type
VdpDeviceData *device; ///< link to parent
pthread_mutex_t lock;
} VdpVideoMixerData;
/** @brief VdpOutputSurface object parameters */
typedef struct {
HandleType type; ///< handle type
VdpDeviceData *device; ///< link to parent
pthread_mutex_t lock;
VdpRGBAFormat rgba_format; ///< RGBA format of data stored
GLuint tex_id; ///< associated GL texture id
GLuint fbo_id; ///< framebuffer object id
uint32_t width;
uint32_t height;
GLuint gl_internal_format; ///< GL texture format: internal format
GLuint gl_format; ///< GL texture format: preferred external format
GLuint gl_type; ///< GL texture format: pixel type
unsigned int bytes_per_pixel; ///< number of bytes per pixel
VdpTime first_presentation_time; ///< first displayed time in queue
VdpPresentationQueueStatus status; ///< status in presentation queue
VdpTime queued_at;
} VdpOutputSurfaceData;
/** @brief VdpPresentationQueueTarget object parameters */
typedef struct {
HandleType type; ///< handle type
VdpDeviceData *device; ///< link to parent
pthread_mutex_t lock;
int refcount;
Drawable drawable; ///< X drawable to output to
GLXContext glc; ///< GL context used for output
} VdpPresentationQueueTargetData;
/** @brief VdpPresentationQueue object parameters */
typedef struct {
HandleType type; ///< handle type
VdpDeviceData *device; ///< link to parent
pthread_mutex_t lock;
VdpPresentationQueueTargetData *target;
VdpColor bg_color; ///< background color
struct {
int head;
int used;
int firstfree;
int freelist[PRESENTATION_QUEUE_LENGTH];
struct {
VdpTime t; ///< earliest_presentation_time
int next;
uint32_t clip_width;
uint32_t clip_height;
VdpOutputSurface surface;
} item[PRESENTATION_QUEUE_LENGTH];
} queue;
pthread_t worker_thread;
pthread_mutex_t queue_mutex;
pthread_cond_t new_work_available;
} VdpPresentationQueueData;
/** @brief VdpVideoSurface object parameters */
typedef struct {
HandleType type; ///< handle type
VdpDeviceData *device; ///< link to parent
pthread_mutex_t lock;
VdpChromaType chroma_type; ///< video chroma type
uint32_t width;
uint32_t stride; ///< distance between first pixels of two consecutive rows
///< in pixels
uint32_t height;
void *y_plane; ///< luma data (software)
void *v_plane; ///< chroma data (software)
void *u_plane; ///< chroma data (software)
VASurfaceID va_surf; ///< VA-API surface
void *va_glx; ///< handle for VA-API/GLX interaction
GLuint tex_id; ///< GL texture id (RGBA)
} VdpVideoSurfaceData;
/** @brief VdpBitmapSurface object parameters */
typedef struct {
HandleType type; ///< handle type
VdpDeviceData *device; ///< link to parent
pthread_mutex_t lock;
VdpRGBAFormat rgba_format; ///< RGBA format of data stored
GLuint tex_id; ///< GL texture id
uint32_t width;
uint32_t height;
VdpBool frequently_accessed;///< 1 if surface should be optimized for frequent access
unsigned int bytes_per_pixel; ///< number of bytes per bitmap pixel
GLuint gl_internal_format; ///< GL texture format: internal format
GLuint gl_format; ///< GL texture format: preferred external format
GLuint gl_type; ///< GL texture format: pixel type
char *bitmap_data; ///< system-memory buffer for frequently accessed bitmaps
int dirty; ///< dirty flag. True if system-memory buffer contains data
///< newer than GPU texture contents
} VdpBitmapSurfaceData;
/** @brief VdpDecoder object parameters */
typedef struct {
HandleType type; ///< handle type
VdpDeviceData *device; ///< link to parent
pthread_mutex_t lock;
VdpDecoderProfile profile; ///< decoder profile
uint32_t width;
uint32_t height;
uint32_t max_references; ///< maximum count of reference frames
VAConfigID config_id; ///< VA-API config id
VASurfaceID render_targets[MAX_RENDER_TARGETS]; ///< spare VA surfaces
uint32_t num_render_targets;
uint32_t next_surface_idx; ///< next free surface in render_targets
VAContextID context_id; ///< VA-API context id
} VdpDecoderData;
VdpStatus
softVdpDeviceCreateX11(Display *display, int screen, VdpDevice *device,
VdpGetProcAddress **get_proc_address);
VdpGetApiVersion softVdpGetApiVersion;
VdpDecoderQueryCapabilities softVdpDecoderQueryCapabilities;
VdpDecoderCreate softVdpDecoderCreate;
VdpDecoderDestroy softVdpDecoderDestroy;
VdpDecoderGetParameters softVdpDecoderGetParameters;
VdpDecoderRender softVdpDecoderRender;
VdpOutputSurfaceQueryCapabilities softVdpOutputSurfaceQueryCapabilities;
VdpOutputSurfaceQueryGetPutBitsNativeCapabilities softVdpOutputSurfaceQueryGetPutBitsNativeCapabilities;
VdpOutputSurfaceQueryPutBitsIndexedCapabilities softVdpOutputSurfaceQueryPutBitsIndexedCapabilities;
VdpOutputSurfaceQueryPutBitsYCbCrCapabilities softVdpOutputSurfaceQueryPutBitsYCbCrCapabilities;
VdpOutputSurfaceCreate softVdpOutputSurfaceCreate;
VdpOutputSurfaceDestroy softVdpOutputSurfaceDestroy;
VdpOutputSurfaceGetParameters softVdpOutputSurfaceGetParameters;
VdpOutputSurfaceGetBitsNative softVdpOutputSurfaceGetBitsNative;
VdpOutputSurfacePutBitsNative softVdpOutputSurfacePutBitsNative;
VdpOutputSurfacePutBitsIndexed softVdpOutputSurfacePutBitsIndexed;
VdpOutputSurfacePutBitsYCbCr softVdpOutputSurfacePutBitsYCbCr;
VdpVideoMixerQueryFeatureSupport softVdpVideoMixerQueryFeatureSupport;
VdpVideoMixerQueryParameterSupport softVdpVideoMixerQueryParameterSupport;
VdpVideoMixerQueryAttributeSupport softVdpVideoMixerQueryAttributeSupport;
VdpVideoMixerQueryParameterValueRange softVdpVideoMixerQueryParameterValueRange;
VdpVideoMixerQueryAttributeValueRange softVdpVideoMixerQueryAttributeValueRange;
VdpVideoMixerCreate softVdpVideoMixerCreate;
VdpVideoMixerSetFeatureEnables softVdpVideoMixerSetFeatureEnables;
VdpVideoMixerSetAttributeValues softVdpVideoMixerSetAttributeValues;
VdpVideoMixerGetFeatureSupport softVdpVideoMixerGetFeatureSupport;
VdpVideoMixerGetFeatureEnables softVdpVideoMixerGetFeatureEnables;
VdpVideoMixerGetParameterValues softVdpVideoMixerGetParameterValues;
VdpVideoMixerGetAttributeValues softVdpVideoMixerGetAttributeValues;
VdpVideoMixerDestroy softVdpVideoMixerDestroy;
VdpVideoMixerRender softVdpVideoMixerRender;
VdpPresentationQueueTargetDestroy softVdpPresentationQueueTargetDestroy;
VdpPresentationQueueCreate softVdpPresentationQueueCreate;
VdpPresentationQueueDestroy softVdpPresentationQueueDestroy;
VdpPresentationQueueSetBackgroundColor softVdpPresentationQueueSetBackgroundColor;
VdpPresentationQueueGetBackgroundColor softVdpPresentationQueueGetBackgroundColor;
VdpPresentationQueueGetTime softVdpPresentationQueueGetTime;
VdpPresentationQueueDisplay softVdpPresentationQueueDisplay;
VdpPresentationQueueBlockUntilSurfaceIdle softVdpPresentationQueueBlockUntilSurfaceIdle;
VdpPresentationQueueQuerySurfaceStatus softVdpPresentationQueueQuerySurfaceStatus;
VdpVideoSurfaceQueryCapabilities softVdpVideoSurfaceQueryCapabilities;
VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities softVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities;
VdpVideoSurfaceCreate softVdpVideoSurfaceCreate;
VdpVideoSurfaceDestroy softVdpVideoSurfaceDestroy;
VdpVideoSurfaceGetParameters softVdpVideoSurfaceGetParameters;
VdpVideoSurfaceGetBitsYCbCr softVdpVideoSurfaceGetBitsYCbCr;
VdpVideoSurfacePutBitsYCbCr softVdpVideoSurfacePutBitsYCbCr;
VdpBitmapSurfaceQueryCapabilities softVdpBitmapSurfaceQueryCapabilities;
VdpBitmapSurfaceCreate softVdpBitmapSurfaceCreate;
VdpBitmapSurfaceDestroy softVdpBitmapSurfaceDestroy;
VdpBitmapSurfaceGetParameters softVdpBitmapSurfaceGetParameters;
VdpBitmapSurfacePutBitsNative softVdpBitmapSurfacePutBitsNative;
VdpDeviceDestroy softVdpDeviceDestroy;
VdpGetInformationString softVdpGetInformationString;
VdpGenerateCSCMatrix softVdpGenerateCSCMatrix;
VdpOutputSurfaceRenderOutputSurface softVdpOutputSurfaceRenderOutputSurface;
VdpOutputSurfaceRenderBitmapSurface softVdpOutputSurfaceRenderBitmapSurface;
VdpPreemptionCallbackRegister softVdpPreemptionCallbackRegister;
VdpPresentationQueueTargetCreateX11 softVdpPresentationQueueTargetCreateX11;
VdpGetProcAddress softVdpGetProcAddress;
#endif /* VDPAU_SOFT_H_ */