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 vl_mpeg12_mc_renderer_h
29 #define vl_mpeg12_mc_renderer_h
31 #include <pipe/p_compiler.h>
32 #include <pipe/p_state.h>
33 #include <pipe/p_video_state.h>
36 struct pipe_video_surface
;
37 struct pipe_macroblock
;
39 /* A slice is video-width (rounded up to a multiple of macroblock width) x macroblock height */
40 enum VL_MPEG12_MC_RENDERER_BUFFER_MODE
42 VL_MPEG12_MC_RENDERER_BUFFER_SLICE
, /* Saves memory at the cost of smaller batches */
43 VL_MPEG12_MC_RENDERER_BUFFER_PICTURE
/* Larger batches, more memory */
46 enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK
48 VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ALL
, /* Waste of memory bandwidth */
49 VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE
, /* Can only do point-filtering when interpolating subsampled chroma channels */
50 VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_NONE
/* Needs conditional texel fetch! */
58 struct vl_mpeg12_mc_renderer
60 struct pipe_context
*pipe
;
61 unsigned picture_width
;
62 unsigned picture_height
;
63 enum pipe_video_chroma_format chroma_format
;
64 enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode
;
65 enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK eb_handling
;
67 unsigned macroblocks_per_batch
;
69 struct pipe_viewport_state viewport
;
70 struct pipe_constant_buffer vs_const_buf
;
71 struct pipe_framebuffer_state fb_state
;
72 struct pipe_vertex_element vertex_elems
[8];
77 struct { void *y
, *cb
, *cr
, *ref
[2]; } individual
;
80 void *i_vs
, *p_vs
[2], *b_vs
[2];
81 void *i_fs
, *p_fs
[2], *b_fs
[2];
85 struct pipe_texture
*all
[5];
86 struct { struct pipe_texture
*y
, *cb
, *cr
, *ref
[2]; } individual
;
91 struct pipe_vertex_buffer all
[3];
92 struct { struct pipe_vertex_buffer ycbcr
, ref
[2]; } individual
;
95 struct pipe_texture
*surface
, *past
, *future
;
96 struct pipe_fence_handle
**fence
;
97 unsigned num_macroblocks
;
98 struct pipe_mpeg12_macroblock
*macroblock_buf
;
99 struct pipe_transfer
*tex_transfer
[3];
101 struct vertex2f surface_tex_inv_size
;
102 struct vertex2f zero_block
[3];
105 bool vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer
*renderer
,
106 struct pipe_context
*pipe
,
107 unsigned picture_width
,
108 unsigned picture_height
,
109 enum pipe_video_chroma_format chroma_format
,
110 enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode
,
111 enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK eb_handling
,
114 void vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer
*renderer
);
116 void vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer
*renderer
,
117 struct pipe_texture
*surface
,
118 struct pipe_texture
*past
,
119 struct pipe_texture
*future
,
120 unsigned num_macroblocks
,
121 struct pipe_mpeg12_macroblock
*mpeg12_macroblocks
,
122 struct pipe_fence_handle
**fence
);
124 #endif /* vl_mpeg12_mc_renderer_h */