1 /**************************************************************************
3 * Copyright 2009 Younes Manton.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #ifndef PIPE_VIDEO_CONTEXT_H
29 #define PIPE_VIDEO_CONTEXT_H
35 #include <pipe/p_video_state.h>
39 struct pipe_macroblock
;
40 struct pipe_picture_desc
;
41 struct pipe_fence_handle
;
44 * Gallium video rendering context
46 struct pipe_video_context
48 struct pipe_screen
*screen
;
50 void *priv
; /**< context private data (for DRI for example) */
53 * destroy context, all objects created from this context
54 * (buffers, decoders, compositors etc...) must be freed before calling this
56 void (*destroy
)(struct pipe_video_context
*context
);
59 * Query an integer-valued capability/parameter/limit
60 * \param param one of PIPE_CAP_x
62 int (*get_param
)(struct pipe_video_context
*context
, int param
);
65 * Check if the given pipe_format is supported as a texture or
68 boolean (*is_format_supported
)(struct pipe_video_context
*context
,
69 enum pipe_format format
,
73 * create a surface of a texture
75 struct pipe_surface
*(*create_surface
)(struct pipe_video_context
*context
,
76 struct pipe_resource
*resource
,
77 const struct pipe_surface
*templ
);
80 * sampler view handling, used for subpictures for example
85 * create a sampler view of a texture, for subpictures for example
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
);
92 * upload image data to a sampler
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
);
101 * clear a sampler with a specific rgba color
103 void (*clear_sampler
)(struct pipe_video_context
*context
,
104 struct pipe_sampler_view
*dst
,
105 const struct pipe_box
*dst_box
,
111 * create a decoder for a specific video profile
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
);
120 * Creates a buffer as decoding target
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
);
128 * Creates a video compositor
130 struct pipe_video_compositor
*(*create_compositor
)(struct pipe_video_context
*context
);
134 * decoder for a specific video codec
136 struct pipe_video_decoder
138 struct pipe_video_context
*context
;
140 enum pipe_video_profile profile
;
141 enum pipe_video_entrypoint entrypoint
;
142 enum pipe_video_chroma_format chroma_format
;
147 * destroy this video decoder
149 void (*destroy
)(struct pipe_video_decoder
*decoder
);
152 * Creates a buffer as decoding input
154 struct pipe_video_decode_buffer
*(*create_buffer
)(struct pipe_video_decoder
*decoder
);
157 * flush decoder buffer to video hardware
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 struct pipe_fence_handle
**fence
);
167 * input buffer for a decoder
169 struct pipe_video_decode_buffer
171 struct pipe_video_decoder
*decoder
;
174 * destroy this decode buffer
176 void (*destroy
)(struct pipe_video_decode_buffer
*decbuf
);
179 * map the input buffer into memory before starting decoding
181 void (*map
)(struct pipe_video_decode_buffer
*decbuf
);
184 * get the pointer where to put the ycbcr blocks of a component
186 struct pipe_ycbcr_block
*(*get_ycbcr_stream
)(struct pipe_video_decode_buffer
*, int component
);
189 * get the pointer where to put the ycbcr dct block data of a component
191 short *(*get_ycbcr_buffer
)(struct pipe_video_decode_buffer
*, int component
);
194 * get the stride of the mv buffer
196 unsigned (*get_mv_stream_stride
)(struct pipe_video_decode_buffer
*decbuf
);
199 * get the pointer where to put the motion vectors of a ref frame
201 struct pipe_motionvector
*(*get_mv_stream
)(struct pipe_video_decode_buffer
*decbuf
, int ref_frame
);
207 void (*decode_bitstream
)(struct pipe_video_decode_buffer
*decbuf
,
209 struct pipe_buffer
**bitstream_buf
);
213 * unmap decoder buffer before flushing
215 void (*unmap
)(struct pipe_video_decode_buffer
*decbuf
);
219 * output for decoding / input for displaying
221 struct pipe_video_buffer
223 struct pipe_video_context
*context
;
225 enum pipe_format buffer_format
;
226 enum pipe_video_chroma_format chroma_format
;
231 * destroy this video buffer
233 void (*destroy
)(struct pipe_video_buffer
*buffer
);
236 * get a individual sampler view for each plane
238 struct pipe_sampler_view
**(*get_sampler_view_planes
)(struct pipe_video_buffer
*buffer
);
241 * get a individual sampler view for each component
243 struct pipe_sampler_view
**(*get_sampler_view_components
)(struct pipe_video_buffer
*buffer
);
246 * get a individual surfaces for each plane
248 struct pipe_surface
**(*get_surfaces
)(struct pipe_video_buffer
*buffer
);
252 * composing and displaying of image data
254 struct pipe_video_compositor
256 struct pipe_video_context
*context
;
259 * destroy this compositor
261 void (*destroy
)(struct pipe_video_compositor
*compositor
);
264 * set yuv -> rgba conversion matrix
266 void (*set_csc_matrix
)(struct pipe_video_compositor
*compositor
, const float mat
[16]);
269 * set overlay samplers
274 * reset all currently set layers
276 void (*clear_layers
)(struct pipe_video_compositor
*compositor
);
279 * set a video buffer as a layer to render
281 void (*set_buffer_layer
)(struct pipe_video_compositor
*compositor
,
283 struct pipe_video_buffer
*buffer
,
284 struct pipe_video_rect
*src_rect
,
285 struct pipe_video_rect
*dst_rect
);
288 * set a paletted sampler as a layer to render
290 void (*set_palette_layer
)(struct pipe_video_compositor
*compositor
,
292 struct pipe_sampler_view
*indexes
,
293 struct pipe_sampler_view
*palette
,
294 struct pipe_video_rect
*src_rect
,
295 struct pipe_video_rect
*dst_rect
);
298 * set a rgba sampler as a layer to render
300 void (*set_rgba_layer
)(struct pipe_video_compositor
*compositor
,
302 struct pipe_sampler_view
*rgba
,
303 struct pipe_video_rect
*src_rect
,
304 struct pipe_video_rect
*dst_rect
);
309 * render the layers to the frontbuffer
311 void (*render_picture
)(struct pipe_video_compositor
*compositor
,
312 enum pipe_mpeg12_picture_type picture_type
,
313 struct pipe_surface
*dst_surface
,
314 struct pipe_video_rect
*dst_area
,
315 struct pipe_fence_handle
**fence
);
323 #endif /* PIPE_VIDEO_CONTEXT_H */