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 * Check if the given pipe_format is supported as a video buffer
61 boolean (*is_format_supported
)(struct pipe_video_context
*context
,
62 enum pipe_format format
,
63 enum pipe_video_profile profile
);
66 * create a surface of a texture
68 struct pipe_surface
*(*create_surface
)(struct pipe_video_context
*context
,
69 struct pipe_resource
*resource
,
70 const struct pipe_surface
*templ
);
73 * sampler view handling, used for subpictures for example
78 * create a sampler view of a texture, for subpictures for example
80 struct pipe_sampler_view
*(*create_sampler_view
)(struct pipe_video_context
*context
,
81 struct pipe_resource
*resource
,
82 const struct pipe_sampler_view
*templ
);
85 * upload image data to a sampler
87 void (*upload_sampler
)(struct pipe_video_context
*context
,
88 struct pipe_sampler_view
*dst
,
89 const struct pipe_box
*dst_box
,
90 const void *src
, unsigned src_stride
,
91 unsigned src_x
, unsigned src_y
);
94 * clear a sampler with a specific rgba color
96 void (*clear_sampler
)(struct pipe_video_context
*context
,
97 struct pipe_sampler_view
*dst
,
98 const struct pipe_box
*dst_box
,
104 * create a decoder for a specific video profile
106 struct pipe_video_decoder
*(*create_decoder
)(struct pipe_video_context
*context
,
107 enum pipe_video_profile profile
,
108 enum pipe_video_entrypoint entrypoint
,
109 enum pipe_video_chroma_format chroma_format
,
110 unsigned width
, unsigned height
);
113 * Creates a buffer as decoding target
115 struct pipe_video_buffer
*(*create_buffer
)(struct pipe_video_context
*context
,
116 enum pipe_format buffer_format
,
117 enum pipe_video_chroma_format chroma_format
,
118 unsigned width
, unsigned height
);
121 * Creates a video compositor
123 struct pipe_video_compositor
*(*create_compositor
)(struct pipe_video_context
*context
);
127 * decoder for a specific video codec
129 struct pipe_video_decoder
131 struct pipe_video_context
*context
;
133 enum pipe_video_profile profile
;
134 enum pipe_video_entrypoint entrypoint
;
135 enum pipe_video_chroma_format chroma_format
;
140 * destroy this video decoder
142 void (*destroy
)(struct pipe_video_decoder
*decoder
);
145 * Creates a buffer as decoding input
147 struct pipe_video_decode_buffer
*(*create_buffer
)(struct pipe_video_decoder
*decoder
);
150 * flush decoder buffer to video hardware
152 void (*flush_buffer
)(struct pipe_video_decode_buffer
*decbuf
,
153 unsigned num_ycbcr_blocks
[3],
154 struct pipe_video_buffer
*ref_frames
[2],
155 struct pipe_video_buffer
*dst
);
159 * input buffer for a decoder
161 struct pipe_video_decode_buffer
163 struct pipe_video_decoder
*decoder
;
166 * destroy this decode buffer
168 void (*destroy
)(struct pipe_video_decode_buffer
*decbuf
);
171 * map the input buffer into memory before starting decoding
173 void (*begin_frame
)(struct pipe_video_decode_buffer
*decbuf
);
176 * set the quantification matrixes
178 void (*set_quant_matrix
)(struct pipe_video_decode_buffer
*decbuf
,
179 const uint8_t intra_matrix
[64],
180 const uint8_t non_intra_matrix
[64]);
183 * get the pointer where to put the ycbcr blocks of a component
185 struct pipe_ycbcr_block
*(*get_ycbcr_stream
)(struct pipe_video_decode_buffer
*, int component
);
188 * get the pointer where to put the ycbcr dct block data of a component
190 short *(*get_ycbcr_buffer
)(struct pipe_video_decode_buffer
*, int component
);
193 * get the stride of the mv buffer
195 unsigned (*get_mv_stream_stride
)(struct pipe_video_decode_buffer
*decbuf
);
198 * get the pointer where to put the motion vectors of a ref frame
200 struct pipe_motionvector
*(*get_mv_stream
)(struct pipe_video_decode_buffer
*decbuf
, int ref_frame
);
205 void (*decode_bitstream
)(struct pipe_video_decode_buffer
*decbuf
,
206 unsigned num_bytes
, const void *data
,
207 struct pipe_mpeg12_picture_desc
*picture
,
208 unsigned num_ycbcr_blocks
[3]);
211 * unmap decoder buffer before flushing
213 void (*end_frame
)(struct pipe_video_decode_buffer
*decbuf
);
217 * output for decoding / input for displaying
219 struct pipe_video_buffer
221 struct pipe_video_context
*context
;
223 enum pipe_format buffer_format
;
224 enum pipe_video_chroma_format chroma_format
;
229 * destroy this video buffer
231 void (*destroy
)(struct pipe_video_buffer
*buffer
);
234 * get a individual sampler view for each plane
236 struct pipe_sampler_view
**(*get_sampler_view_planes
)(struct pipe_video_buffer
*buffer
);
239 * get a individual sampler view for each component
241 struct pipe_sampler_view
**(*get_sampler_view_components
)(struct pipe_video_buffer
*buffer
);
244 * get a individual surfaces for each plane
246 struct pipe_surface
**(*get_surfaces
)(struct pipe_video_buffer
*buffer
);
250 * composing and displaying of image data
252 struct pipe_video_compositor
254 struct pipe_video_context
*context
;
257 * destroy this compositor
259 void (*destroy
)(struct pipe_video_compositor
*compositor
);
262 * set yuv -> rgba conversion matrix
264 void (*set_csc_matrix
)(struct pipe_video_compositor
*compositor
, const float mat
[16]);
267 * reset dirty area, so it's cleared with the clear colour
269 void (*reset_dirty_area
)(struct pipe_video_compositor
*compositor
);
272 * set the clear color
274 void (*set_clear_color
)(struct pipe_video_compositor
*compositor
, float color
[4]);
277 * set overlay samplers
282 * reset all currently set layers
284 void (*clear_layers
)(struct pipe_video_compositor
*compositor
);
287 * set a video buffer as a layer to render
289 void (*set_buffer_layer
)(struct pipe_video_compositor
*compositor
,
291 struct pipe_video_buffer
*buffer
,
292 struct pipe_video_rect
*src_rect
,
293 struct pipe_video_rect
*dst_rect
);
296 * set a paletted sampler as a layer to render
298 void (*set_palette_layer
)(struct pipe_video_compositor
*compositor
,
300 struct pipe_sampler_view
*indexes
,
301 struct pipe_sampler_view
*palette
,
302 struct pipe_video_rect
*src_rect
,
303 struct pipe_video_rect
*dst_rect
);
306 * set a rgba sampler as a layer to render
308 void (*set_rgba_layer
)(struct pipe_video_compositor
*compositor
,
310 struct pipe_sampler_view
*rgba
,
311 struct pipe_video_rect
*src_rect
,
312 struct pipe_video_rect
*dst_rect
);
317 * render the layers to the frontbuffer
319 void (*render_picture
)(struct pipe_video_compositor
*compositor
,
320 enum pipe_mpeg12_picture_type picture_type
,
321 struct pipe_surface
*dst_surface
,
322 struct pipe_video_rect
*dst_area
,
323 struct pipe_fence_handle
**fence
);
331 #endif /* PIPE_VIDEO_CONTEXT_H */