1
by Jens Kuske
First release |
1 |
/*
|
2 |
* Copyright (c) 2013 Jens Kuske <jenskuske@gmail.com>
|
|
3 |
*
|
|
4 |
* This library is free software; you can redistribute it and/or
|
|
5 |
* modify it under the terms of the GNU Lesser General Public
|
|
6 |
* License as published by the Free Software Foundation; either
|
|
7 |
* version 2.1 of the License, or (at your option) any later version.
|
|
8 |
*
|
|
9 |
* This library is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12 |
* Lesser General Public License for more details.
|
|
13 |
*
|
|
14 |
* You should have received a copy of the GNU Lesser General Public
|
|
15 |
* License along with this library; if not, write to the Free Software
|
|
16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
||
20 |
#ifndef __VDPAU_PRIVATE_H__
|
|
21 |
#define __VDPAU_PRIVATE_H__
|
|
22 |
||
23 |
#define DEBUG
|
|
24 |
#define MAX_HANDLES 64
|
|
25 |
#define VBV_SIZE (1 * 1024 * 1024)
|
|
26 |
||
27 |
#include <stdlib.h> |
|
71
by Jens Kuske
Use libcedrus |
28 |
#include <cedrus/cedrus.h> |
1
by Jens Kuske
First release |
29 |
#include <vdpau/vdpau.h> |
57
by Jens Kuske
Use predefined types for vdp_* functions |
30 |
#include <vdpau/vdpau_x11.h> |
1
by Jens Kuske
First release |
31 |
#include <X11/Xlib.h> |
59.1.9
by Jens Kuske
Move disp code to seperate files |
32 |
#include "sunxi_disp.h" |
72
by Andreas Baierl
Add CPU fallback for G2D |
33 |
#include "pixman.h" |
1
by Jens Kuske
First release |
34 |
|
14
by Reimar Döffinger
Support vdp_video_surface_put_bits_y_cb_cr. |
35 |
#define INTERNAL_YCBCR_FORMAT (VdpYCbCrFormat)0xffff
|
36 |
||
1
by Jens Kuske
First release |
37 |
typedef struct |
38 |
{
|
|
71
by Jens Kuske
Use libcedrus |
39 |
cedrus_t *cedrus; |
1
by Jens Kuske
First release |
40 |
Display *display; |
41 |
int screen; |
|
42 |
VdpPreemptionCallback *preemption_callback; |
|
43 |
void *preemption_callback_context; |
|
44 |
int fd; |
|
16.1.1
by Jens Kuske
Add basic output surface support with g2d |
45 |
int g2d_fd; |
16.1.11
by Jens Kuske
Make OSD support runtime switchable through VDPAU_OSD environment variable |
46 |
int osd_enabled; |
72
by Andreas Baierl
Add CPU fallback for G2D |
47 |
int g2d_enabled; |
1
by Jens Kuske
First release |
48 |
} device_ctx_t; |
49 |
||
38
by Jens Kuske
Don't overwrite VideoSurface data while it is still needed for OutputSurface |
50 |
typedef struct |
51 |
{
|
|
52 |
int ref_count; |
|
71
by Jens Kuske
Use libcedrus |
53 |
cedrus_mem_t *data; |
38
by Jens Kuske
Don't overwrite VideoSurface data while it is still needed for OutputSurface |
54 |
} yuv_data_t; |
55 |
||
24
by Jens Kuske
Unify interface to different decoders (now more object-oriented) |
56 |
typedef struct video_surface_ctx_struct |
1
by Jens Kuske
First release |
57 |
{
|
58 |
device_ctx_t *device; |
|
59 |
uint32_t width, height; |
|
60 |
VdpChromaType chroma_type; |
|
61 |
VdpYCbCrFormat source_format; |
|
38
by Jens Kuske
Don't overwrite VideoSurface data while it is still needed for OutputSurface |
62 |
yuv_data_t *yuv; |
59.1.4
by Jens Kuske
Add reconstruct buffer to video surface |
63 |
int luma_size, chroma_size; |
71
by Jens Kuske
Use libcedrus |
64 |
cedrus_mem_t *rec; |
24
by Jens Kuske
Unify interface to different decoders (now more object-oriented) |
65 |
void *decoder_private; |
66 |
void (*decoder_private_free)(struct video_surface_ctx_struct *surface); |
|
1
by Jens Kuske
First release |
67 |
} video_surface_ctx_t; |
68 |
||
69 |
typedef struct decoder_ctx_struct |
|
70 |
{
|
|
71 |
uint32_t width, height; |
|
72 |
VdpDecoderProfile profile; |
|
71
by Jens Kuske
Use libcedrus |
73 |
cedrus_mem_t *data; |
1
by Jens Kuske
First release |
74 |
device_ctx_t *device; |
24
by Jens Kuske
Unify interface to different decoders (now more object-oriented) |
75 |
VdpStatus (*decode)(struct decoder_ctx_struct *decoder, VdpPictureInfo const *info, const int len, video_surface_ctx_t *output); |
76 |
void *private; |
|
77 |
void (*private_free)(struct decoder_ctx_struct *decoder); |
|
1
by Jens Kuske
First release |
78 |
} decoder_ctx_t; |
79 |
||
80 |
typedef struct |
|
81 |
{
|
|
82 |
Drawable drawable; |
|
59.1.9
by Jens Kuske
Move disp code to seperate files |
83 |
struct sunxi_disp *disp; |
1
by Jens Kuske
First release |
84 |
} queue_target_ctx_t; |
85 |
||
86 |
typedef struct |
|
87 |
{
|
|
88 |
queue_target_ctx_t *target; |
|
89 |
VdpColor background; |
|
90 |
device_ctx_t *device; |
|
91 |
} queue_ctx_t; |
|
92 |
||
93 |
typedef struct |
|
94 |
{
|
|
95 |
device_ctx_t *device; |
|
23
by Reimar Döffinger
Add hackish support for brightness, contrast and saturation. |
96 |
int csc_change; |
97 |
float brightness; |
|
98 |
float contrast; |
|
99 |
float saturation; |
|
100 |
float hue; |
|
1
by Jens Kuske
First release |
101 |
} mixer_ctx_t; |
102 |
||
31
by Jens Kuske
Only draw/clear dirty area of output_surface |
103 |
#define RGBA_FLAG_DIRTY (1 << 0)
|
32
by Jens Kuske
Only flush cache of rgba_surface data when needed |
104 |
#define RGBA_FLAG_NEEDS_FLUSH (1 << 1)
|
34
by Jens Kuske
Only clear rgba_surface if it won't get overwritten anyway |
105 |
#define RGBA_FLAG_NEEDS_CLEAR (1 << 2)
|
31
by Jens Kuske
Only draw/clear dirty area of output_surface |
106 |
|
1
by Jens Kuske
First release |
107 |
typedef struct |
108 |
{
|
|
109 |
device_ctx_t *device; |
|
30
by Jens Kuske
Merge common parts of bitmap_surface and output_surface into rgba_surface |
110 |
VdpRGBAFormat format; |
1
by Jens Kuske
First release |
111 |
uint32_t width, height; |
71
by Jens Kuske
Use libcedrus |
112 |
cedrus_mem_t *data; |
31
by Jens Kuske
Only draw/clear dirty area of output_surface |
113 |
VdpRect dirty; |
114 |
uint32_t flags; |
|
72
by Andreas Baierl
Add CPU fallback for G2D |
115 |
pixman_image_t *pimage; |
30
by Jens Kuske
Merge common parts of bitmap_surface and output_surface into rgba_surface |
116 |
} rgba_surface_t; |
117 |
||
59.1.9
by Jens Kuske
Move disp code to seperate files |
118 |
typedef struct output_surface_ctx_struct |
30
by Jens Kuske
Merge common parts of bitmap_surface and output_surface into rgba_surface |
119 |
{
|
120 |
rgba_surface_t rgba; |
|
1
by Jens Kuske
First release |
121 |
video_surface_ctx_t *vs; |
38
by Jens Kuske
Don't overwrite VideoSurface data while it is still needed for OutputSurface |
122 |
yuv_data_t *yuv; |
21
by zaps166
Correct zooming |
123 |
VdpRect video_src_rect, video_dst_rect; |
23
by Reimar Döffinger
Add hackish support for brightness, contrast and saturation. |
124 |
int csc_change; |
125 |
float brightness; |
|
126 |
float contrast; |
|
127 |
float saturation; |
|
128 |
float hue; |
|
1
by Jens Kuske
First release |
129 |
} output_surface_ctx_t; |
130 |
||
16.1.4
by Paul Kendall
Initial bitmap surface support |
131 |
typedef struct |
132 |
{
|
|
30
by Jens Kuske
Merge common parts of bitmap_surface and output_surface into rgba_surface |
133 |
rgba_surface_t rgba; |
16.1.4
by Paul Kendall
Initial bitmap surface support |
134 |
VdpBool frequently_accessed; |
135 |
} bitmap_surface_ctx_t; |
|
136 |
||
1
by Jens Kuske
First release |
137 |
#ifndef ARRAY_SIZE
|
138 |
#define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
|
|
139 |
#endif
|
|
140 |
||
31
by Jens Kuske
Only draw/clear dirty area of output_surface |
141 |
#define max(a, b) \
|
142 |
({ __typeof__ (a) _a = (a); \
|
|
143 |
__typeof__ (b) _b = (b); \
|
|
144 |
_a > _b ? _a : _b; })
|
|
145 |
||
146 |
#define min(a, b) \
|
|
147 |
({ __typeof__ (a) _a = (a); \
|
|
148 |
__typeof__ (b) _b = (b); \
|
|
149 |
_a < _b ? _a : _b; })
|
|
150 |
||
151 |
#define min_nz(a, b) \
|
|
152 |
({ __typeof__ (a) _a = (a); \
|
|
153 |
__typeof__ (b) _b = (b); \
|
|
154 |
_a < _b ? (_a == 0 ? _b : _a) : (_b == 0 ? _a : _b); })
|
|
155 |
||
59.1.7
by Jens Kuske
Add H.265 support on H3 |
156 |
#define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi)
|
157 |
||
158 |
#define ceil_log2(n) ((n) <= 1 ? 0 : 32 - __builtin_clz((n) - 1))
|
|
159 |
||
42
by Jens Kuske
Fix VideoSurface size |
160 |
#define ALIGN(x, a) (((x) + ((typeof(x))(a) - 1)) & ~((typeof(x))(a) - 1))
|
59.1.7
by Jens Kuske
Add H.265 support on H3 |
161 |
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
|
162 |
||
42
by Jens Kuske
Fix VideoSurface size |
163 |
|
1
by Jens Kuske
First release |
164 |
#ifdef DEBUG
|
165 |
#include <stdio.h> |
|
166 |
#define VDPAU_DBG(format, ...) fprintf(stderr, "[VDPAU SUNXI] " format "\n", ##__VA_ARGS__)
|
|
11
by Jens Kuske
Make most debug messages print only once |
167 |
#define VDPAU_DBG_ONCE(format, ...) do { static uint8_t __once; if (!__once) { fprintf(stderr, "[VDPAU SUNXI] " format "\n", ##__VA_ARGS__); __once = 1; } } while(0)
|
1
by Jens Kuske
First release |
168 |
#else
|
169 |
#define VDPAU_DBG(format, ...)
|
|
11
by Jens Kuske
Make most debug messages print only once |
170 |
#define VDPAU_DBG_ONCE(format, ...)
|
1
by Jens Kuske
First release |
171 |
#endif
|
172 |
||
47
by Jens Kuske
Hide internal symbols in shared library |
173 |
#define EXPORT __attribute__ ((visibility ("default")))
|
174 |
||
24
by Jens Kuske
Unify interface to different decoders (now more object-oriented) |
175 |
VdpStatus new_decoder_mpeg12(decoder_ctx_t *decoder); |
176 |
VdpStatus new_decoder_h264(decoder_ctx_t *decoder); |
|
46
by Jens Kuske
Rename mp4 to mpeg4 |
177 |
VdpStatus new_decoder_mpeg4(decoder_ctx_t *decoder); |
59.1.7
by Jens Kuske
Add H.265 support on H3 |
178 |
VdpStatus new_decoder_h265(decoder_ctx_t *decoder); |
24
by Jens Kuske
Unify interface to different decoders (now more object-oriented) |
179 |
|
38
by Jens Kuske
Don't overwrite VideoSurface data while it is still needed for OutputSurface |
180 |
void yuv_unref(yuv_data_t *yuv); |
181 |
yuv_data_t *yuv_ref(yuv_data_t *yuv); |
|
182 |
VdpStatus yuv_prepare(video_surface_ctx_t *video_surface); |
|
59.1.4
by Jens Kuske
Add reconstruct buffer to video surface |
183 |
VdpStatus rec_prepare(video_surface_ctx_t *video_surface); |
38
by Jens Kuske
Don't overwrite VideoSurface data while it is still needed for OutputSurface |
184 |
|
48
by Jens Kuske
Simplify handle creation |
185 |
typedef uint32_t VdpHandle; |
186 |
||
187 |
void *handle_create(size_t size, VdpHandle *handle); |
|
188 |
void *handle_get(VdpHandle handle); |
|
189 |
void handle_destroy(VdpHandle handle); |
|
1
by Jens Kuske
First release |
190 |
|
57
by Jens Kuske
Use predefined types for vdp_* functions |
191 |
EXPORT VdpDeviceCreateX11 vdp_imp_device_create_x11; |
192 |
VdpDeviceDestroy vdp_device_destroy; |
|
193 |
VdpPreemptionCallbackRegister vdp_preemption_callback_register; |
|
194 |
||
195 |
VdpGetProcAddress vdp_get_proc_address; |
|
196 |
||
197 |
VdpGetErrorString vdp_get_error_string; |
|
198 |
VdpGetApiVersion vdp_get_api_version; |
|
199 |
VdpGetInformationString vdp_get_information_string; |
|
200 |
||
201 |
VdpPresentationQueueTargetCreateX11 vdp_presentation_queue_target_create_x11; |
|
202 |
VdpPresentationQueueTargetDestroy vdp_presentation_queue_target_destroy; |
|
203 |
VdpPresentationQueueCreate vdp_presentation_queue_create; |
|
204 |
VdpPresentationQueueDestroy vdp_presentation_queue_destroy; |
|
205 |
VdpPresentationQueueSetBackgroundColor vdp_presentation_queue_set_background_color; |
|
206 |
VdpPresentationQueueGetBackgroundColor vdp_presentation_queue_get_background_color; |
|
207 |
VdpPresentationQueueGetTime vdp_presentation_queue_get_time; |
|
208 |
VdpPresentationQueueDisplay vdp_presentation_queue_display; |
|
209 |
VdpPresentationQueueBlockUntilSurfaceIdle vdp_presentation_queue_block_until_surface_idle; |
|
210 |
VdpPresentationQueueQuerySurfaceStatus vdp_presentation_queue_query_surface_status; |
|
211 |
||
212 |
VdpVideoSurfaceCreate vdp_video_surface_create; |
|
213 |
VdpVideoSurfaceDestroy vdp_video_surface_destroy; |
|
214 |
VdpVideoSurfaceGetParameters vdp_video_surface_get_parameters; |
|
215 |
VdpVideoSurfaceGetBitsYCbCr vdp_video_surface_get_bits_y_cb_cr; |
|
216 |
VdpVideoSurfacePutBitsYCbCr vdp_video_surface_put_bits_y_cb_cr; |
|
217 |
VdpVideoSurfaceQueryCapabilities vdp_video_surface_query_capabilities; |
|
218 |
VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vdp_video_surface_query_get_put_bits_y_cb_cr_capabilities; |
|
219 |
||
220 |
VdpOutputSurfaceCreate vdp_output_surface_create; |
|
221 |
VdpOutputSurfaceDestroy vdp_output_surface_destroy; |
|
222 |
VdpOutputSurfaceGetParameters vdp_output_surface_get_parameters; |
|
223 |
VdpOutputSurfaceGetBitsNative vdp_output_surface_get_bits_native; |
|
224 |
VdpOutputSurfacePutBitsNative vdp_output_surface_put_bits_native; |
|
225 |
VdpOutputSurfacePutBitsIndexed vdp_output_surface_put_bits_indexed; |
|
226 |
VdpOutputSurfacePutBitsYCbCr vdp_output_surface_put_bits_y_cb_cr; |
|
227 |
VdpOutputSurfaceRenderOutputSurface vdp_output_surface_render_output_surface; |
|
228 |
VdpOutputSurfaceRenderBitmapSurface vdp_output_surface_render_bitmap_surface; |
|
229 |
VdpOutputSurfaceQueryCapabilities vdp_output_surface_query_capabilities; |
|
230 |
VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vdp_output_surface_query_get_put_bits_native_capabilities; |
|
231 |
VdpOutputSurfaceQueryPutBitsIndexedCapabilities vdp_output_surface_query_put_bits_indexed_capabilities; |
|
232 |
VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vdp_output_surface_query_put_bits_y_cb_cr_capabilities; |
|
233 |
||
234 |
VdpVideoMixerCreate vdp_video_mixer_create; |
|
235 |
VdpVideoMixerDestroy vdp_video_mixer_destroy; |
|
236 |
VdpVideoMixerRender vdp_video_mixer_render; |
|
237 |
VdpVideoMixerGetFeatureSupport vdp_video_mixer_get_feature_support; |
|
238 |
VdpVideoMixerSetFeatureEnables vdp_video_mixer_set_feature_enables; |
|
239 |
VdpVideoMixerGetFeatureEnables vdp_video_mixer_get_feature_enables; |
|
240 |
VdpVideoMixerSetAttributeValues vdp_video_mixer_set_attribute_values; |
|
241 |
VdpVideoMixerGetParameterValues vdp_video_mixer_get_parameter_values; |
|
242 |
VdpVideoMixerGetAttributeValues vdp_video_mixer_get_attribute_values; |
|
243 |
VdpVideoMixerQueryFeatureSupport vdp_video_mixer_query_feature_support; |
|
244 |
VdpVideoMixerQueryParameterSupport vdp_video_mixer_query_parameter_support; |
|
245 |
VdpVideoMixerQueryParameterValueRange vdp_video_mixer_query_parameter_value_range; |
|
246 |
VdpVideoMixerQueryAttributeSupport vdp_video_mixer_query_attribute_support; |
|
247 |
VdpVideoMixerQueryAttributeValueRange vdp_video_mixer_query_attribute_value_range; |
|
248 |
VdpGenerateCSCMatrix vdp_generate_csc_matrix; |
|
249 |
||
250 |
VdpDecoderCreate vdp_decoder_create; |
|
251 |
VdpDecoderDestroy vdp_decoder_destroy; |
|
252 |
VdpDecoderGetParameters vdp_decoder_get_parameters; |
|
253 |
VdpDecoderRender vdp_decoder_render; |
|
254 |
VdpDecoderQueryCapabilities vdp_decoder_query_capabilities; |
|
255 |
||
256 |
VdpBitmapSurfaceCreate vdp_bitmap_surface_create; |
|
257 |
VdpBitmapSurfaceDestroy vdp_bitmap_surface_destroy; |
|
258 |
VdpBitmapSurfaceGetParameters vdp_bitmap_surface_get_parameters; |
|
259 |
VdpBitmapSurfacePutBitsNative vdp_bitmap_surface_put_bits_native; |
|
260 |
VdpBitmapSurfaceQueryCapabilities vdp_bitmap_surface_query_capabilities; |
|
1
by Jens Kuske
First release |
261 |
|
262 |
#endif
|