Merge branch 'master' of ssh://git.freedesktop.org/git/mesa/mesa into pipe-video
[mesa.git] / src / gallium / auxiliary / vl / vl_mpeg12_mc_renderer.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 vl_mpeg12_mc_renderer_h
29 #define vl_mpeg12_mc_renderer_h
30
31 #include <pipe/p_compiler.h>
32 #include <pipe/p_state.h>
33 #include <pipe/p_video_state.h>
34 #include "vl_types.h"
35
36 struct pipe_context;
37 struct pipe_macroblock;
38 struct keymap;
39
40 /* A slice is video-width (rounded up to a multiple of macroblock width) x macroblock height */
41 enum VL_MPEG12_MC_RENDERER_BUFFER_MODE
42 {
43 VL_MPEG12_MC_RENDERER_BUFFER_SLICE, /* Saves memory at the cost of smaller batches */
44 VL_MPEG12_MC_RENDERER_BUFFER_PICTURE /* Larger batches, more memory */
45 };
46
47 enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK
48 {
49 VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ALL, /* Waste of memory bandwidth */
50 VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE, /* Can only do point-filtering when interpolating subsampled chroma channels */
51 VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_NONE /* Needs conditional texel fetch! */
52 };
53
54 struct vl_mpeg12_mc_renderer
55 {
56 struct pipe_context *pipe;
57 unsigned picture_width;
58 unsigned picture_height;
59 enum pipe_video_chroma_format chroma_format;
60 enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode;
61 enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK eb_handling;
62 bool pot_buffers;
63 unsigned macroblocks_per_batch;
64
65 struct pipe_viewport_state viewport;
66 struct pipe_resource *vs_const_buf;
67 struct pipe_framebuffer_state fb_state;
68 union
69 {
70 void *all[3];
71 struct { void *i, *p, *b; } individual;
72 } vertex_elems_state;
73
74 union
75 {
76 void *all[5];
77 struct { void *y, *cb, *cr, *ref[2]; } individual;
78 } samplers;
79
80 union
81 {
82 struct pipe_sampler_view *all[5];
83 struct { struct pipe_sampler_view *y, *cb, *cr, *ref[2]; } individual;
84 } sampler_views;
85
86 void *i_vs, *p_vs[2], *b_vs[2];
87 void *i_fs, *p_fs[2], *b_fs[2];
88
89 union
90 {
91 struct pipe_resource *all[5];
92 struct { struct pipe_resource *y, *cb, *cr, *ref[2]; } individual;
93 } textures;
94
95 union
96 {
97 struct pipe_vertex_buffer all[3];
98 struct { struct pipe_vertex_buffer ycbcr, ref[2]; } individual;
99 } vertex_bufs;
100
101 struct pipe_surface *surface, *past, *future;
102 struct pipe_fence_handle **fence;
103 unsigned num_macroblocks;
104 struct pipe_mpeg12_macroblock *macroblock_buf;
105 struct pipe_transfer *tex_transfer[3];
106 short *texels[3];
107 struct vertex2f surface_tex_inv_size;
108 struct vertex2f zero_block[3];
109
110 struct keymap *texview_map;
111 };
112
113 bool vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer *renderer,
114 struct pipe_context *pipe,
115 unsigned picture_width,
116 unsigned picture_height,
117 enum pipe_video_chroma_format chroma_format,
118 enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode,
119 enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK eb_handling,
120 bool pot_buffers);
121
122 void vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer);
123
124 void vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer *renderer,
125 struct pipe_surface *surface,
126 struct pipe_surface *past,
127 struct pipe_surface *future,
128 unsigned num_macroblocks,
129 struct pipe_mpeg12_macroblock *mpeg12_macroblocks,
130 struct pipe_fence_handle **fence);
131
132 #endif /* vl_mpeg12_mc_renderer_h */