[g3dvl] move dummy quantification into xvmc state tracker
[mesa.git] / src / gallium / include / pipe / p_video_context.h
1 /**************************************************************************
2 *
3 * Copyright 2009 Younes Manton.
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 PIPE_VIDEO_CONTEXT_H
29 #define PIPE_VIDEO_CONTEXT_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #include <pipe/p_video_state.h>
36
37 struct pipe_screen;
38 struct pipe_surface;
39 struct pipe_macroblock;
40 struct pipe_picture_desc;
41 struct pipe_fence_handle;
42
43 /**
44 * Gallium video rendering context
45 */
46 struct pipe_video_context
47 {
48 struct pipe_screen *screen;
49
50 void *priv; /**< context private data (for DRI for example) */
51
52 /**
53 * destroy context, all objects created from this context
54 * (buffers, decoders, compositors etc...) must be freed before calling this
55 */
56 void (*destroy)(struct pipe_video_context *context);
57
58 /**
59 * Query an integer-valued capability/parameter/limit
60 * \param param one of PIPE_CAP_x
61 */
62 int (*get_param)(struct pipe_video_context *context, int param);
63
64 /**
65 * Check if the given pipe_format is supported as a texture or
66 * drawing surface.
67 */
68 boolean (*is_format_supported)(struct pipe_video_context *context,
69 enum pipe_format format,
70 unsigned usage);
71
72 /**
73 * create a surface of a texture
74 */
75 struct pipe_surface *(*create_surface)(struct pipe_video_context *context,
76 struct pipe_resource *resource,
77 const struct pipe_surface *templ);
78
79 /**
80 * sampler view handling, used for subpictures for example
81 */
82 /*@{*/
83
84 /**
85 * create a sampler view of a texture, for subpictures for example
86 */
87 struct pipe_sampler_view *(*create_sampler_view)(struct pipe_video_context *context,
88 struct pipe_resource *resource,
89 const struct pipe_sampler_view *templ);
90
91 /**
92 * upload image data to a sampler
93 */
94 void (*upload_sampler)(struct pipe_video_context *context,
95 struct pipe_sampler_view *dst,
96 const struct pipe_box *dst_box,
97 const void *src, unsigned src_stride,
98 unsigned src_x, unsigned src_y);
99
100 /**
101 * clear a sampler with a specific rgba color
102 */
103 void (*clear_sampler)(struct pipe_video_context *context,
104 struct pipe_sampler_view *dst,
105 const struct pipe_box *dst_box,
106 const float *rgba);
107
108 /*}@*/
109
110 /**
111 * create a decoder for a specific video profile
112 */
113 struct pipe_video_decoder *(*create_decoder)(struct pipe_video_context *context,
114 enum pipe_video_profile profile,
115 enum pipe_video_entrypoint entrypoint,
116 enum pipe_video_chroma_format chroma_format,
117 unsigned width, unsigned height);
118
119 /**
120 * Creates a buffer as decoding target
121 */
122 struct pipe_video_buffer *(*create_buffer)(struct pipe_video_context *context,
123 enum pipe_format buffer_format,
124 enum pipe_video_chroma_format chroma_format,
125 unsigned width, unsigned height);
126
127 /**
128 * Creates a video compositor
129 */
130 struct pipe_video_compositor *(*create_compositor)(struct pipe_video_context *context);
131 };
132
133 /**
134 * decoder for a specific video codec
135 */
136 struct pipe_video_decoder
137 {
138 struct pipe_video_context *context;
139
140 enum pipe_video_profile profile;
141 enum pipe_video_entrypoint entrypoint;
142 enum pipe_video_chroma_format chroma_format;
143 unsigned width;
144 unsigned height;
145
146 /**
147 * destroy this video decoder
148 */
149 void (*destroy)(struct pipe_video_decoder *decoder);
150
151 /**
152 * Creates a buffer as decoding input
153 */
154 struct pipe_video_decode_buffer *(*create_buffer)(struct pipe_video_decoder *decoder);
155
156 /**
157 * flush decoder buffer to video hardware
158 */
159 void (*flush_buffer)(struct pipe_video_decode_buffer *decbuf,
160 unsigned num_ycbcr_blocks[3],
161 struct pipe_video_buffer *ref_frames[2],
162 struct pipe_video_buffer *dst);
163 };
164
165 /**
166 * input buffer for a decoder
167 */
168 struct pipe_video_decode_buffer
169 {
170 struct pipe_video_decoder *decoder;
171
172 /**
173 * destroy this decode buffer
174 */
175 void (*destroy)(struct pipe_video_decode_buffer *decbuf);
176
177 /**
178 * map the input buffer into memory before starting decoding
179 */
180 void (*begin_frame)(struct pipe_video_decode_buffer *decbuf);
181
182 /**
183 * set the quantification matrixes
184 */
185 void (*set_quant_matrix)(struct pipe_video_decode_buffer *decbuf,
186 const uint8_t intra_matrix[64],
187 const uint8_t non_intra_matrix[64]);
188
189 /**
190 * get the pointer where to put the ycbcr blocks of a component
191 */
192 struct pipe_ycbcr_block *(*get_ycbcr_stream)(struct pipe_video_decode_buffer *, int component);
193
194 /**
195 * get the pointer where to put the ycbcr dct block data of a component
196 */
197 short *(*get_ycbcr_buffer)(struct pipe_video_decode_buffer *, int component);
198
199 /**
200 * get the stride of the mv buffer
201 */
202 unsigned (*get_mv_stream_stride)(struct pipe_video_decode_buffer *decbuf);
203
204 /**
205 * get the pointer where to put the motion vectors of a ref frame
206 */
207 struct pipe_motionvector *(*get_mv_stream)(struct pipe_video_decode_buffer *decbuf, int ref_frame);
208
209 /**
210 * decode a bitstream
211 */
212 void (*decode_bitstream)(struct pipe_video_decode_buffer *decbuf,
213 unsigned num_bytes, const void *data,
214 struct pipe_mpeg12_picture_desc *picture,
215 unsigned num_ycbcr_blocks[3]);
216
217 /**
218 * unmap decoder buffer before flushing
219 */
220 void (*end_frame)(struct pipe_video_decode_buffer *decbuf);
221 };
222
223 /**
224 * output for decoding / input for displaying
225 */
226 struct pipe_video_buffer
227 {
228 struct pipe_video_context *context;
229
230 enum pipe_format buffer_format;
231 enum pipe_video_chroma_format chroma_format;
232 unsigned width;
233 unsigned height;
234
235 /**
236 * destroy this video buffer
237 */
238 void (*destroy)(struct pipe_video_buffer *buffer);
239
240 /**
241 * get a individual sampler view for each plane
242 */
243 struct pipe_sampler_view **(*get_sampler_view_planes)(struct pipe_video_buffer *buffer);
244
245 /**
246 * get a individual sampler view for each component
247 */
248 struct pipe_sampler_view **(*get_sampler_view_components)(struct pipe_video_buffer *buffer);
249
250 /**
251 * get a individual surfaces for each plane
252 */
253 struct pipe_surface **(*get_surfaces)(struct pipe_video_buffer *buffer);
254 };
255
256 /**
257 * composing and displaying of image data
258 */
259 struct pipe_video_compositor
260 {
261 struct pipe_video_context *context;
262
263 /**
264 * destroy this compositor
265 */
266 void (*destroy)(struct pipe_video_compositor *compositor);
267
268 /**
269 * set yuv -> rgba conversion matrix
270 */
271 void (*set_csc_matrix)(struct pipe_video_compositor *compositor, const float mat[16]);
272
273 /**
274 * reset dirty area, so it's cleared with the clear colour
275 */
276 void (*reset_dirty_area)(struct pipe_video_compositor *compositor);
277
278 /**
279 * set the clear color
280 */
281 void (*set_clear_color)(struct pipe_video_compositor *compositor, float color[4]);
282
283 /**
284 * set overlay samplers
285 */
286 /*@{*/
287
288 /**
289 * reset all currently set layers
290 */
291 void (*clear_layers)(struct pipe_video_compositor *compositor);
292
293 /**
294 * set a video buffer as a layer to render
295 */
296 void (*set_buffer_layer)(struct pipe_video_compositor *compositor,
297 unsigned layer,
298 struct pipe_video_buffer *buffer,
299 struct pipe_video_rect *src_rect,
300 struct pipe_video_rect *dst_rect);
301
302 /**
303 * set a paletted sampler as a layer to render
304 */
305 void (*set_palette_layer)(struct pipe_video_compositor *compositor,
306 unsigned layer,
307 struct pipe_sampler_view *indexes,
308 struct pipe_sampler_view *palette,
309 struct pipe_video_rect *src_rect,
310 struct pipe_video_rect *dst_rect);
311
312 /**
313 * set a rgba sampler as a layer to render
314 */
315 void (*set_rgba_layer)(struct pipe_video_compositor *compositor,
316 unsigned layer,
317 struct pipe_sampler_view *rgba,
318 struct pipe_video_rect *src_rect,
319 struct pipe_video_rect *dst_rect);
320
321 /*@}*/
322
323 /**
324 * render the layers to the frontbuffer
325 */
326 void (*render_picture)(struct pipe_video_compositor *compositor,
327 enum pipe_mpeg12_picture_type picture_type,
328 struct pipe_surface *dst_surface,
329 struct pipe_video_rect *dst_area,
330 struct pipe_fence_handle **fence);
331
332 };
333
334 #ifdef __cplusplus
335 }
336 #endif
337
338 #endif /* PIPE_VIDEO_CONTEXT_H */