Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

p_video_context.h 10KB

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